#發問 C語言 Declaration與Definition的困擾
國立臺北科技大學
本人電機系大一,最近在自學C語言,目前閱讀The C Programming Language第二版(K&R2)對於書中變數declaration與definition的敘述感到困惑,由於沒找到程式語言相關版,於是想請教軟體工程師版上的各位前輩一些疑問。如書中p.33所述:
"Definition" refers to the place where the variable is created or assigned storage; "declaration" refers to places where the nature of the variable is stated but no storage is allocated.
文中也提到了對於變數的宣告須使用extern關鍵字,但在開頭p.9又提到這樣的例子:
A declaration announces the properties of variables; it consists of a name and a list of variables, such as
int fahr, celsius;
int lower, upper, step;
在我的觀念中,這已不單單是declaration而已,而是declare"並且"define,而往後讀到p.35又發現類似的困惑:
Declarations list the variables to be used, and state what type they have and perhaps what their initial values are.
為何declarations又會perhaps state what their initial values are呢?
我希望紮實地學C語言,並搞清楚各類專有名詞的定義,希望有前輩能指點迷津,謝謝。
