我正在尝试使用c为2维数组分配内存,我在visual studio 2008中得到一个例外.
int Count=16383,N=14;
char **result=(char**)malloc(sizeof(char)*Count);
for(int i=1;i<=Count;i++)
result[i] = (char*)malloc(sizeof(char)*N);
Unhandled exception at 0x012e1692 in combination.exe: 0xC0000005:
Access violation writing location 0x00590000
Run Code Online (Sandbox Code Playgroud)
当我是11272并且我无法理解为什么时会发生异常!
char **result=(char**)malloc(sizeof(char)*Count);
Run Code Online (Sandbox Code Playgroud)
应该
char **result=(char**)malloc(sizeof(char*)*Count);
Run Code Online (Sandbox Code Playgroud)