나는이 내 기능에 경고를 컴파일하고 내 코드에서 오류를 찾을 수 없습니다지고있어파일을 쓰는 동안 경고를 컴파일합니다. 뭐가 잘못 되었나요?</p> <p>경고 :
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
'''문자가 문제가됩니다. 개별 문자에만 작은 따옴표를 사용하십시오. 문자열에는 큰 따옴표를 사용하십시오. –
' '/ dev/fan/rpm'' --->' "/ dev/fan/rpm"' – BLUEPIXY