Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
brimpa
on Feb 25, 2012
|
parent
|
context
|
favorite
| on:
C Programming Puzzlers
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.
cygx
on Feb 25, 2012
|
next
[–]
It's valid (see C99 6.7.8 §20 and §22) and equivalent to
int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
Sniffnoy
on Feb 25, 2012
|
prev
[–]
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...
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: