Y
Hacker News
new
|
ask
|
show
|
jobs
by
brimpa
5223 days ago
For question 7, can someone confirm that
int a[][3] = {1, 2, 3, 4, 5, 6};
is not a typo and is, in fact, a valid array initialization? I've never come across this and think it's rather unintuitive.
2 comments
cygx
5223 days ago
It's valid (see C99 6.7.8 §20 and §22) and equivalent to
int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
link
Sniffnoy
5223 days ago
Checking the rules for array initialization in Harbison & Steele, this does indeed seem to be invalid. I'm surprised, I actually thought that was valid...
link