Re: When you declare an array of chars and store a string in it, where is the position of the null character \0? And what happens to the unused memory locations?
by "Default User" <defaultuserbr@[EMAIL PROTECTED]
>
May 6, 2008 at 04:59 PM
arnuld wrote:
> > On Mon, 05 May 2008 15:17:44 -0700, Peter Nilsson wrote:
>
> > You need to be careful though of situations like...
> >
> > char foo[5] = "dudes";
> >
> > C, unlike C++, allows such an initialisation. There is no
> > terminating null stored as there is no room for it.
>
>
> yes and you get garbage on the screen:
> printf("%s\n", oye);
No, you get undefined behavior.
Brian