Is this a valid C statement ?
Posted
by
Philando Gullible
on Stack Overflow
See other posts from Stack Overflow
or by Philando Gullible
Published on 2010-12-31T21:33:57Z
Indexed on
2010/12/31
21:54 UTC
Read the original article
Hit count: 127
Lets say I write char c[99] = {'Stack Overflow'};
in C or C++ it does compiles fine but does this valid? By valid I meant not invoking any kind of undefined or unspecified behavior.
Again if I write char c[99] = 'Stack Overflow';
gcc complains about multicharacter constant which is obvious but in the above when I am enclosing within curly brackets compiler is happy! why is it so ?
I also notice that puts(c);
after the first statement will output 'w' precisely the last character of a general string in-place of Stack Overflow
. why so ?
Could somebody explain this behavior may be separately.
© Stack Overflow or respective owner