Array Initialization - (nf)

lee at ut-ngp.UUCP lee at ut-ngp.UUCP
Sat Jul 9 06:02:29 AEST 1983


All globals and statics in C are initialized to zero. Globals are
identifiers declared outside of any function without a storage-class
specifier. This is part of the C definition and all C compilers should
guarantee this. Auto identifiers are typically not initialized (you
should definitely not expect them to be) because they are allocated on
the stack and disappear every time you leave a function and are created
every time you enter the function. This is also why most C compilers
don't allow you to initialize autos. If you allow auto initialization,
then your C compiler must generate code that assigns the correct value
to the auto upon every entry to the function. It's usually cheaper to
explicitly do the assignment yourself.



More information about the Comp.lang.c mailing list