level 8
wangbiao170
楼主
方式一、
double* VAL_DIA = (double*)malloc(VAL_DIA_size*sizeof(double));
方式二、
void* new_array(int number,int size){
void* a = (void*)malloc(number*size);
return a;
}
double* VAL_DIA=(double*)new_array(VAL_DIA_size,sizeof(double));
这两种方式开辟内存有什么区别吗?为什么第二种在使用的时候会出错。
错误报告:Segmentation fault (core dumped)
2015年01月20日 03点01分
1
double* VAL_DIA = (double*)malloc(VAL_DIA_size*sizeof(double));
方式二、
void* new_array(int number,int size){
void* a = (void*)malloc(number*size);
return a;
}
double* VAL_DIA=(double*)new_array(VAL_DIA_size,sizeof(double));
这两种方式开辟内存有什么区别吗?为什么第二种在使用的时候会出错。
错误报告:Segmentation fault (core dumped)