Let's say I char c[99] = {'Stack Overflow'}; writing char c[99] = {'Stack Overflow'}; in C or C ++. It compiles fine, but is it really? In fact, I meant not to refer to any type of undefined or undefined behavior.
Again, if I write char c[99] = 'Stack Overflow'; gcc complains about a multi-character constant that is obvious, but in the example above, when I enclose in curly braces, the compiler is happy! Why is this so?
I also notice that puts(c); after the first statement prints 'w', it is the last character of the common string instead of Stack Overflow . Why is that?
Can someone explain this behavior separately?
c ++ c gcc
Quixotic
source share