Re: Array initalization doubt.

From: Dhruv Ahuja (dhruvahuja_at_gmail.com)
Date: 11/01/04


Date: 1 Nov 2004 10:45:38 -0800

No, this will only initialise the first element, s[0] to a zero. The
remaining 29 will have a 'garbage' uninitialised value. To set all an
array's elements to zero, you should do this: char s[30] = { 0 );



Relevant Pages

  • Re: Interview question: variable initialisation
    ... system which doesn't initialise all global memory at the start. ... the startup code _might_ initialize all of the RAM to zero ... that all uninitialized static lifetime variables in C are initialized ... apply to 'auto' variables, which are usually stack-based and do not ...
    (comp.arch.embedded)
  • Re: Interview question: variable initialisation
    ... system which doesn't initialise all global memory at the start. ... the startup code _might_ initialize all of the RAM to zero ... that all uninitialized static lifetime variables in C are initialized ... apply to 'auto' variables, which are usually stack-based and do not ...
    (comp.arch.embedded)
  • Re: Separator Line in Toolbox menus
    ... It can save all sorts of problems if you later change the scope of a variable to one thats not implicitly zero initialised. ... adviced not to initialise static variables if their value was 0 just to avoid potentional impact on binary size for all the different compilers they are and will be using. ... Does someone know if zero initialised areas of C ROM components are created during runtime or are flattened in ROM space during build/link time? ... Implicitly or explictly zero value static variables 'small' in size are placed in a r/w data area while the larger onces are placed in a zero initialised area. ...
    (comp.sys.acorn.programmer)
  • Re: Division % error
    ... Are you familiar the phrase "garbage in, ... because you might not be using the correct computation for the ... and the denominator is not zero. ... I have a minus in cell "B3" and when I ...
    (microsoft.public.excel)
  • Re: Double arrays in ext. code garbage when viewed in labview.
    ... NumericArrayResize to allow for my code to allocate memory in arrays ... the only problem comes because labview is not looking at the bytes ... seems to always show up as zero in labview, regardless of what I set it ... the double so as to see this, but still this first element is always ...
    (comp.lang.labview)