GCC 中的段错误

来源:互联网 发布:sns网络平台 编辑:程序博客网 时间:2024/05/16 10:22
网上的资料,编译通不过
......
double a=123.456;
char *sh;
gcvt(a,6,sh);                                  //double convert to char stream
printf("%s/n",sh);
......
$ make -f MaketC
$
段错误

Why?
sh指针定义时,尚未指定指向内存的地址,gcc认定此为错误

Howto:
"char *sh;"  ---->  "char *sh=(char *)malloc(256);"
原创粉丝点击