Hey guys I start to programming c and I had one question about malloc. Malloc allocate memory. In my example I allocate memory for one integer. But I had enough memory for an int array with 3 ints. Why does it correct compile?
int *array=malloc(1*sizeof(int));
array[0]=1;
array[1]=2;
array[2]=3;
array[3]=4;
array[4]=5;
int i;
for(i=0;i<5;i++) {
printf("%d",array[i]);
}