通常你的程序编译通过,但是在run或者debug时报错,常见原因有:
(1)在使用动态数组时,索引超出长度:
double* a = new double[n]; //n = 3
a[4] = 0.0; //索引只有0, 1, 2
(2)释放了分配的内存,但又使用了该变量
char *a= (char *)malloc(10);
free(a);
strcpy(a, "hello");
通常你的程序编译通过,但是在run或者debug时报错,常见原因有:
(1)在使用动态数组时,索引超出长度:
double* a = new double[n]; //n = 3
a[4] = 0.0; //索引只有0, 1, 2
(2)释放了分配的内存,但又使用了该变量
char *a= (char *)malloc(10);
free(a);
strcpy(a, "hello");