warning: deprecated conversion from string constant to 字符型指

软件和网站开发以及相关技术探讨
回复
mz57
帖子: 6
注册时间: 2015-11-22 17:26
系统: ubuntu14.04

warning: deprecated conversion from string constant to 字符型指

#1

帖子 mz57 » 2015-11-25 20:56

报错内容:warning: deprecated conversion from string constant to ‘char*’
我用的是ubuntu14.04下的g++
程序代码:
char *file1;

FILE *h_file;

strcpy(file1,"Hmatrix");

h_file = open_file_std(file1,"wb");



#include "open.h"
FILE *open_file_std ( char *fname,char *mode )
{
if (strcmp(fname,"-")==0)
{ switch (mode[0])
{ case 'r':
{ return stdin;
}
case 'w':
{ return stdout;
}
default:
{ fprintf(stderr,"Bad mode passed to open_file_std: %s\n",mode);
exit(1);
}
}
}
else
{ return fopen(fname,mode);
}
}
回复