initializing an array of char

Is the following supposed to be legal or not legal?

static char const x[4] = "foo\0";

Yes, I understand the compiler is nice enough to do that for me with:

static char const x[] = "foo";

but because I am using a code generator that spits out other embedded NUL
bytes and offsets into this character array, it is simply more convenient
to insert my own NUL byte and tell the compiler exactly how many bytes to
allocate for the thing. All is fine with "C", but I'm having problems
with C++. Thank you!!
If you want to specify specific characters, try initializing the array like this:
1
2
char array[] = { 'h', 'e', 'l', 'l', 'o' }        // NO NULL
char array2[] = { 'h', 'e', 'l', 'l', 'o', '\0' }        // NULL 


Or just use std::strings.
Topic archived. No new replies allowed.