int main()
{
int *p=NULL;
p=malloc(8);
if (p==NULL)
printf("Mem alloc failed\n");
else
printf("Passed\n");
unsigned long int i=0;
for (i=2;i<=10000;i++)
p[i]=10; // I thought as we are increasing beyond malloc size of 8 bytes there should be segmentation fault but I was wrong.
printf("p[10000]= %d %d\n",p[10000]);
free(p);
return 0;
}
What can be the reason behind this as I tried to increase for loop count to
pow(2,32) ( for(i=2;i<=((pow(2,32)-1));i++))
in which case I get a segmentation fault?