Re: char array not terminated with \0
From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 01/17/05
- Next message: Old Wolf: "Re: Error E2349 tester.c 29: Nonportable pointer conversion"
- Previous message: Mike Wahler: "Re: Comparing two numbers"
- In reply to: Artie Gold: "Re: char array not terminated with \0"
- Next in thread: Anders Christensen: "Re: char array not terminated with \0"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 Jan 2005 21:23:21 GMT
"Artie Gold" <artiegold@austin.rr.com> wrote in message
news:35182lF4cf691U1@individual.net...
> thesushant@rediffmail.com wrote:
> > hi,
> > statements like char str[12]="012345678901", dont suffix "\0" after the
> > array of characters or strings on its own . or the programmer has to
> > give it explicitly??????????????
> >
> Don't top post. I've snipped the original message, as yours provides
> enough context.
>
> The issue in the definition above is that the array `str' is declared to
> have sufficient room for only 12 chars; the '\0' would be appended *if
> there was room for it*.
For completeness:
Also, a '\0' would be appended if the size were computed
by the compiler, as happens when no size is explicitly specified:
char str[] = "abc"; /* array size is 4 */
-Mike
- Next message: Old Wolf: "Re: Error E2349 tester.c 29: Nonportable pointer conversion"
- Previous message: Mike Wahler: "Re: Comparing two numbers"
- In reply to: Artie Gold: "Re: char array not terminated with \0"
- Next in thread: Anders Christensen: "Re: char array not terminated with \0"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|