函数'If'的隐式声明
Implicit Declaration of Function 'If'
我目前正在尝试创建一个快速程序,让你有机会在10次猜测中猜测一个预定的数字(我希望这个数字是28)。如果你符合猜测,你会被告知"恭喜!你猜对了数字。"如果你没有达到猜测,你将被告知"再试一次!"直到你的尝试次数用完或猜对为止
这是我当前的代码: int main(void){
int Chance, Guess;
printf ("You have 10 chances to guess the number between 0-50.n");
for (Chance=0; Chance<10; Chance++)
{
scanf("%d",&Guess);
If (Guess==28)
printf("Congrats! You have guess the number!");
Else If (Guess!=28)
printf("Try Again!n");
}
printf("You are all out of tries.");
return 0;
}
这是我的错误列表:编译错误时间:0内存:0信号:0
prog.c:在函数'main'中:
prog.c:9:3:警告:函数"If"的隐式声明[-Wimplicit函数声明]如果(Guess==28)^
prog.c:10:4:错误:应为";"printf"之前printf("恭喜!你猜对了数字!");^
prog.c:11:3:错误:未知类型名称"Else"Else If(猜测!=28)^prog.c:11:17:错误:在"!="之前应为")"代币Else If(猜测!=28)^
如有任何帮助,我们将不胜感激
if
和else
子句以小写字母开头。实际上,所有的C和C++保留字都以小写字母或下划线开头。
C和C++语言都区分大小写。
相关文章:
- 如何在 if 语句中声明对象并在任何我想的地方使用它?
- 结构声明中的 if 语句C++
- 是否可以在 "if" 语句中声明变量?
- 在 if 语句中声明时如何访问类对象?(在 C++ 中)
- 我如何在一个 if 语句中声明所有数字我尝试通过其他方式声明所有数字,如果一个接一个,但似乎代码有逻辑错误
- 是否可以使用"if constexpr"来声明具有不同类型和init-expr的变量
- 为什么if语句和变量声明要比循环中的添加更快
- 是否可以使用指向语句中声明的变量地址的指针"if"
- 有没有修复我的代码没有将 int 声明为我在 if else 循环中选择的内容
- 在“if constexpr”块中声明的变量的范围
- 如何在 if. 中使用变量.然后..C++中的声明
- 为什么"constructor-way"在"for-loop"允许但不允许"if-statement"声明变量?
- 在IF中声明派生类以供外部使用
- 使用if语句选择类型来声明变量C++
- 如何在 if 条件中声明变量
- C++ if 语句中声明变量
- 稍后在程序中使用if-else构造内部声明的变量会导致未声明的标识符错误
- 函数'If'的隐式声明
- C++在if-else内部声明派生类对象,并在外部使用它
- 表达式跟进中的变量声明'if'