
January 1st, 2003, 04:42 PM
|
|
.
|
|
Join Date: Dec 2002
Posts: 296
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
c - don't understand something in k&r book
following c programming by kernighan and ritchie at the moment.
something doesn't add up. contradicts:
(page 40) - talking about variable declerations - "if the variable in question is not automatic, the initialization is done once only, conceptually before the program starts executing, and the initializer must be a constant expression"
then when talking about scope rules (page 80) - "the scope of an external variable or a function lasts from the point at which it is declared to the end of the file being compiled"
this seems to be a contradiction to me. the first part i've quoted gives the impression that variables that are outside any functions (not automatic), an external variable, (regardless of their position in the code) will be available from the start of the code.
where as the other part says that it's available from the point it's initialised downwards - and that's what more of that section round page 80 gives the impresssion of.
if an external variable is initialised some way down the code, then this will not be initialised conceptually before the program starts. i'm guessing the 2nd part is correct?
|