#include
#include
#define SIZE 40
#define ANSWER "Grant"
char* s_gets(char* st, int n);
int main(void)
{
char try[SIZE];
puts("Who is buried in Grant's tomb?");
s_gets(try, SIZE);
int is_right = 1;
while (strlen(try) != strlen(ANSWER))
{
puts("No, that's wrong. Try again.");
s_gets(try, SIZE);
}
for (int i = 0; i < strlen(ANSWER); i++)
if (try[i] != ANSWER[i])
is_right = 0;
if (!(is_right))
{
puts("No, that's wrong. Try again.");
s_gets(try, SIZE);
}
else
puts("That's right!");
return 0;
}
char* s_gets(char* st, int n)
{
int i = 0;
char* ret_val;
C PRIMER PLUS 第11章 程序清单11.20 nogo.c程序
![](https://img-home.csdnimg.cn/images/20240711042549.png)