Here is an example that might be a little more pertinant to you:
Code:
int a, c, b = 10;
char array[10];
for(a = 0; a <= b; a++) {
c = array[a];
}
The above code will probably give you a seg fault. If you add in a printf() statement like so:
Code:
int a, c, b = 10;
char array[10];
for(a = 0; a <= b; a++) {
printf("About to access index %d\n",a);
c = array[a];
}
You will (hopefully) get the seg fault before it prints "About to access index 10". This helps you to realize that you are accessing the array outside its bounds.