用ubuntu编译c语言时,int arr[3000][3000];
这样写会导致编译出现段错误(转储内核)问题。
解决方法:用malloc打开空间就可以了。 在c中使用new
例如,定义3000*3000的矩阵
# include stdio.h # definen 3000 int main ({ int * * arr 1; ARR1=(int** ) malloc ) n*sizeof ) int* ); for(intI=0; iN; I () arr1[I]=(int* ) malloc ) n*sizeof(int ) ); }返回0; }以这种方式解决了段错误(转储核心)问题。