[英]conflicting types AND previous implicit declaration in C
skeleton.c:86:6: warning: conflicting types for ‘verifyWord’ [enabled by default]
void verifyWord(char nword) {
^
skeleton.c:79:3: note: previous implicit declaration of ‘verifyWord’ was here
verifyWord(nextword);
^
void playgame() {
.
.
.
strcpy(curword, get_random_word(dictptr));
for(;;) {
.
.
.
/*function for nextword if correct*/
verifyWord(nextword);
/* */
} /* end for loop */
.
.
.
}
void verifyWord(char nword) {
FILE * fp;
fp = fopen ("usedWords.txt", "a+");
fprintf(fp, "%d ", nword);
fclose(fp);
}
Hi, this program is supposed to be a mini word game, i am new to C. Need some help in figuring out how can i avoid the error shown in the imgur image. 嗨,这个程序应该是一个迷你文字游戏,我是C的新手。需要一些帮助找出我如何避免imgur图像中显示的错误。
the above 2 is a playgame function and a verifyWord function 上面的2是一个playgame函数和一个verifyWord函数
Please point me in the right direction as i tried declaring above the main: 当我尝试在主要内容上方进行声明时,请向我指出正确的方向:
You need to declare the function correctly with the arguments you are willing to pass in it. 您需要使用愿意传递的参数正确声明函数。
Let's say for example that verifyWord
returns void
and accepts char pointer
as an argument. 例如,
verifyWord
返回void
并接受char pointer
作为参数。
The proper declaration would be: 正确的声明是:
void verifyWord (char *nextWord);
And you will use it like: 您将像这样使用它:
char* nextWord = NULL;
verifyWord(nextword);
Your problem is that you didn't tell your compiler how to deal with the function. 您的问题是您没有告诉编译器如何处理该函数。 You need to have explicit declaration, like the one I mentioned above, placed somewhere before the line where you call it, and it has to be within the same scope.
您需要有一个明确的声明,如我上面提到的那样,放置在调用它的行之前的某处,并且必须在同一范围内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.