OT: Requesting C advice

Matthew Saltzman mjs at clemson.edu
Thu May 31 13:49:38 UTC 2007


On Thu, 31 May 2007, Mike McCarty wrote:

> Andy Green wrote:
>> Mike McCarty wrote:
>
> [snip]
>
>>> C doesn't initialize what? It initializes all used variables.
>> 
>> 
>> Not if they're on the stack.  You should get a compiler warning
>> nowadays... but don't count on it!
>
> Erm, C knows nothing about a "stack". However, it is true
> that automatic variable are not necessarily initialized.
> I should have stated that all statically allocated variables
> are initialized. Thanks for the correction.

For completeness, dynamically allocated memory is not initialized either, 
unless allocated with calloc() (in which case, it is initialized to 
zeros) or realloc() (in which case, any added space is not initialized).

>
> Mike
>

-- 
 		Matthew Saltzman

Clemson University Math Sciences
mjs AT clemson DOT edu
http://www.math.clemson.edu/~mjs




More information about the fedora-list mailing list