我試圖使用釋放calloc創造1000個字符長字符串動態數組:動態字符串數組dosent工作
int i;
char** strarr =(char**)calloc(argc,sizeof(char)*1000);
if(strarr == NULL)
return 0;
strarr[0][0] ='a';
printf("%c\n",strarr[0][0]);
每次我嘗試運行這段代碼我上的printf線分割的錯,我不明白爲什麼會發生這種情況(您可以假定argc大於0) 謝謝
Ps對不起,該代碼是在文本格式,但使用im移動,所以我沒有這個代碼功能
'strarr [0]'是一個空指針。 'strarr [0] [0]'是未定義的行爲。 – aschepler