我在一个程序中做了一个while循环,程序到达了while循环,但它没有执行。我觉得我错过了一个非常小的错误,因为我已经查看了这么长时间的代码。
int strbuf = 100;
char string[strbuf];
char *exit = "exit";
while(!strcmp(string, exit)){
printf("Enter a word to search. Enter exit to quit");
scanf("%s", string);
state = present(fIndex, string);
if(state){
printf("The word %s was found on line %d", string, state);
}
}
编辑:输入来自键盘。编辑编辑:新代码(同样的问题)
int strbuf = 100;
char string[strbuf];
char *exit = "exit";
printf("Enter a word to search. Enter exit to quit\n");
scanf("%s", string);
while(!strcmp(string, exit)){
state = present(fIndex, string);
if(state){
printf("The word %s was found on line %d", string, state);
}
else printf("The word %s was not found", string);
}