如题所述
用: strcmp(huida,"yes")==0 判断 为 yes (大小写区分):
#include<stdio.h>
int main(){
char huida[10];
int i=0;
while(1){
printf("%d answer yes or no\n",i++);
scanf(" %s",huida);
if ( strcmp(huida,"yes")==0) printf("answer is yes\n");
else {printf("Your answer is not yes !\n"); break;};
}
return 0;
}
#include<stdio.h>
int main(){
char huida[10];
int i=0;
while(1){
printf("%d answer yes or no\n",i++);
scanf(" %s",huida);
if ( strcmp(huida,"yes")==0) printf("answer is yes\n");
else {printf("Your answer is not yes !\n"); break;};
}
return 0;
}
温馨提示:答案为网友推荐,仅供参考