我得到这些编译警告,在我的功能并不能找到我的代码的任何错误:编写文件时编译警告,最新错误?
警告:
src.c: In function ‘writeFiles’:
src.c:119:18: warning: character constant too long for its type [enabled by default]
src.c:119:2: warning: passing argument 1 of ‘fopen’ makes pointer from integer without a cast [enabled by default]
/usr/include/stdio.h:269:14: note: expected ‘const char * __restrict__’ but argument is of type ‘int’
我的功能:
FILE *outfile;
int writeFiles(int pwm, int rpm)
{
outfile = fopen('/dev/fan/rpm', "w+"); /* line 119 with the warnings */ /*create the new file */
fprintf(outfile, "%d", rpm); /*write the rpm to the file */
fclose(outfile); /*close the file */
return (0);
}
我希望你能帮助我解决这个问题。 google和stackoverflow都不能帮助找到解决这个问题的办法。
你能在你的代码片段中标出给出警告的行号吗?另外'fopen'需要一个char *作为第一个参数,为什么你的分隔符是单引号? – Ryan 2013-05-03 19:28:04
'''字符是你的问题。仅为单个字符使用单引号。对于字符串使用双引号。 – 2013-05-03 19:30:23
''/ dev/fan/rpm'' --->'“/ dev/fan/rpm”' – BLUEPIXY 2013-05-03 19:31:10