Ben Combee <[EMAIL PROTECTED]> wrote:
> Huh? CW honors the \0 escape for both character literals and strings. I
> should know -- I rewrote a lot of that escape parsing code.
[...]
> The problem here is actually that the user is specifying a string of 11
> characters -- even with the escaped NULs, there still is the terminating
> NUL.
Huh? I hope you weren't labouring under this misconception when you
rewrote that escape parsing code! (Well, I suppose initialisation is
separate enough from parsing escapes that there wouldn't have been a
problem.)
The Standard even has an example demonstrating the paragraph that states
that the terminating NUL in an initialisation doesn't initialise if there
is no room for it. [1]
> And, as Aaron pointed out, if you specify a partial array in C, the
> compiler is obligated to zero-fill.
Indeed, "char s[5] = { 'a', 'b', 'c' };" is required to initialise s[3] and
s[4] to '\0'. This is true for "char s[5] = "abc";" too in C99 (section
6.7.8 paragraph 21), but if there's an equivalent requirement in C89 I
haven't seen it.
John "must stamp out misleading pedantry! :-) especially on Fridays!"
[1] Initialisation is of course completely different from other situations.
For example, if in an "assignment" in a StrCopy there is no room for a
terminating NUL, that terminating NUL will happy trash other memory,
not be quietly ignored like in an initialisation.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/