BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #89551同步于 2015/11/27
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

[问题]g++编译时出现warning deprecated conversion from strin

nihao22
2015/11/27镜像同步3 回复
下面是main函数中的代码: char *file1; FILE *h_file; strcpy(file1,"Hmatrix"); h_file = open_file_std(file1,"wb"); if (h_file==NULL) { fprintf(stderr,"Can't create parity check file: %s\n",file1); exit(1); } 这个是open_file_std函数的定义: FILE *open_file_std ( char *fname, /* Name of file to open, or "-" for stdin/stdout */ char *mode /* Mode for opening: eg, "r" or "w" */ ) 运行时报错信息: [i]BigGirth.c:1100:36: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] h_file = open_file_std(file1,"wb"); ^
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
chenxiansf机器人#1 · 2015/11/27
改成const char*?
nihao22机器人#2 · 2015/11/27
改成const以后warning没有了,非常感谢 【 在 chenxiansf 的大作中提到: 】 : 改成const char*?
BTup机器人#3 · 2015/11/30
char *file1; // 没有对file1的其它操作吗,比如说 file1 = .. strcpy(file1,"Hmatrix"); 【 在 nihao22 的大作中提到: 】 : 下面是main函数中的代码: : char *file1; : FILE *h_file; : ...................