Hacker News new | ask | show | jobs
by burgerbrain 5468 days ago
sizeof behavior is just icing over what is really going on. You might as well argue that arrays really exist because we have the [] operator.
1 comments

No not really. What's really going on is that A has been declared as an array of 16 ints, while aa has been declared as a pointer to int. Those are different types, and C treats them differently sometimes (but not all times).
Aside from the additional information that the C compiler is capable of knowing about in the case of A, it is the same crap going on under the hood.
You're not writing in under-the-hood, though, you are writing in C. If you want to properly understand compiler warnings and errors you need to know that arrays and pointers are separate types.

Yes, "under the hood" it might be the same, but that's true of many languages if you dig deep enough. C is just a little closer. Yes, at one level a char declaration is just a smaller minimum memory allocation than int, but C will check both those types and if you want to use C properly you'll want to understand its typing and casting rules.