标签: c arrays allocation corruption
mid= n / 2;//(where n is 10) int left[sizeof(mid)];
但是编译器为4 [0,1,2,3]个元素分配空间,它假设分配5 [0,1,2,3,4]个元素。
可能是什么问题?
答案 0 :(得分:3)
sizeof表示:内存中的大小。 int是内存中的4个字节。所以sizeof(int)= 4。
sizeof
你可能想写int left[mid];
int left[mid];