Jonathan Bartlett wrote:
adelfino wrote:
I mean:
unsigned char foo[bar] = "";
is the same as:
unsigned char foo[bar];
memset (foo, '\0', bar);
I believe the former only sets the first character to \0 while the
second will set all of them.
You're entitled to believe whatever you like (have you
heard about the faked Moon landings?), but you might want to
put your faith to the test by reading Section 6.7.8 paragraph 21:
"If there are [...] fewer characters in a string
literal used to initialize an array of known size
than there are elements in the array, the remainder
of the aggregate shall be initialized implicitly the
same as objects that have static storage duration."
.... and paragraph 10:
"[...] If an object that has static storage duration
is not initialized explicitly, then [...] if it has
arithmetic type, it is initialized to [...] zero [...]"
--
Eric Sosman
es*****@acm-dot-org.invalid