Path: utzoo!attcan!uunet!lll-winken!ncis!helios.ee.lbl.gov!nosc!ucsd!ucbvax!decwrl!labrea!rutgers!att!homxb!hound!rkl1 From: rkl1@hound.UUCP (K.LAUX) Newsgroups: comp.lang.c Subject: Re: static versus auto initialization Message-ID: <2877@hound.UUCP> Date: 19 Jan 89 17:09:43 GMT References: <8901182125.AA06523@decwrl.dec.com> Organization: AT&T Bell Laboratories, Holmdel Lines: 27 In article <8901182125.AA06523@decwrl.dec.com>, devine@cookie.dec.com (Bob Devine) writes: ) ) Would someone explain to me why the discrepancy between the ) uninitialized elements of static and auto arrays? ) ) The problem looks like this: ) ) static char abc_static [5] = { 'a', 'b', 'c' }; ) ) main() ) { ) auto char abc_auto [5] = { 'a', 'b', 'c' }; ) . . . ) } ) ) For `abc_static', elements [3] and [4] are guarenteed to be zeroed ) out. However, for `abc_auto', the same elements are garbage. ) Correct. (What more do you need? :-) ). Unless you want to know that the Static has all elements initialized at Compile Time and for Auto there is actual code to only initialize the specified elements, the rest defaulting to whatever was in the memory allocated for the array. --rkl