c语言 - 看不到错误



由于某种原因,我看不到我的代码哪里有问题。

#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;
}

/谢谢/

提示:

$ gcc main.c                                                                   
main.c: In function ‘main’:
main.c:10:11: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Wformat=]
scanf("%s", &age);
^
$ 

最新更新