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;
}
当我试图将循环计数增加到
pow(2,32) ( for(i=2;i<=((pow(2,32)-1));i++))
在这种情况下我会遇到分段错误?