Gotchas: Difference between revisions

m
Line 172:
 
However, arrays are zero-indexed, so in your code you'll never actually want to read from that subscript. Doing so indexes the array out of bounds, reading or writing the address of whatever happens to be stored in memory after it.
 
Chances are this will compile even though it's not something you really want to have happen.
<syntaxhighlight lang="C">int foo[4] = {4,8,12,16};
int x = foo[0]; //x = 4
1,489

edits