What is this array declaration?
After solving a practical question, I always look at Red Coder's solution. I saw an array declaration today that I have never seen before. He declared an array something like this
char a[' '],b[' '];
Please let me know what it is?
PS. This may be a recurring question. I actually searched for it but couldn't find anything about it (maybe because I didn't know what to look for), if it is a duplicate please close the question and give me a link.
source to share
Single quotes are a character constant.
-
' '
can be a space that32
is ASCII. -
' '
can be an embedded TAB character, which is9
ASCII -
' '
can be two spaces to be implementation specificint
.
In any case, you can specify any expression that is an integer type (or convertible to one) inside []
an array declaration. So you get sizeof a
32
either 9
or the implementation-defined value.
source to share