为什么这段代码会抛出一个SIGSEGV:
int main()
{
unsigned long toshuffle[9765625];
unsigned long i;
for (i=0; i< 1000; i++)
toshuffle[i]= i;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
指针将不胜感激.(没有双关语:))
Gyö*_*sek 16
使用malloc()来获取那么多内存.你堆满了.
unsigned long *toshuffle = malloc(9765625 * sizeof(unsigned long));
Run Code Online (Sandbox Code Playgroud)
当然,当你完成它之后,你需要释放()它.
注意:在C++中,您需要将指针强制转换为正确的类型.