Declaration for an array in C is:
type name [elements];
So why doesn't this code throw an exception such as "out of bounds" or any other exception?
#include <stdio.h>
void main()
{
int a[5];
a[7]=75;
printf("%d",a[7]);
}
Declaration for an array in C is:
type name [elements];
So why doesn't this code throw an exception such as "out of bounds" or any other exception?
#include <stdio.h>
void main()
{
int a[5];
a[7]=75;
printf("%d",a[7]);
}
Because in C the variable with the name of the array is the pointer to the first memory-cell of the array and the number between brackets is the offset of the data you want from the starting of the array, it doesn't check if it is a memory cell of the array or not.