4. The Shocking Truth: C Arrays and Pointers Are NOT the Same!
Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.
—Stan Kelly-Bootle
arrays are NOT pointers...why doesn’t my code work?...what’s a declaration? what’s a definition?...match your declarations to thedefinition...array and pointer differences...some light relief—fun with palindromes!
Arrays Are NOT Pointers!
One of the first things that novice C programmers often hear is that “arrays are the same as pointers.” Unfortunately, this is a dangerous half-truth. The ANSI C Standard paragraph 6.5.4.2 recommends that you
Note the distinction between the declarations:
extern int *x;extern int y[];
The first declares x
to be ...
Get Expert C Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.