-1
出于某种原因,我看不到我的代码出现错误。看不到错误
#include <stdio.h>
#include <stdlib.h>
int main()
{
int age;
printf("How old are you \n");
scanf("%s", &age);
if (age > 18){
printf("You may enter \n");
}
/* this above is all that my program runs, always prints "You may enter"*/
if (age < 18){
printf("Nothing to see here \n");
}
return 0;
}
/感谢/
'的scanf( “%S”,&age);'这是一个在'int'使用'%D'转来转去你的编译器警告修改为迂腐级别并将它们视为错误现代编译器将标记关于格式说明符不匹配的警告与提供的参数有关的内容 – WhozCraig
'age'是一个'int',而不是一个字符串,尝试'scanf(“%d “,&age);' – yano