In C/C++, array indices start at zero and go to N-1.
Therefore:
Code:
char word[4]; /* declare a character array with four elements */
word[0] = 'a'; /* first element of the array */
word[1] = 'b'; /* second element of the array */
word[2] = 'c'; /* third element of the array */
word[3] = 'd'; /* fourth element of the array */
/*
These are the only elements available.
This is not allowed:
word[4] = 'e'; // fifth element, but you only declared four!
This goes past the boundaries of the array, hence an overrun
*/
Also, if you're using 'C' style strings, you need space in the array for the "invisible" null character, which indicates the end of the string.