为什么我总是,总不能让他循环输入,用while的话一输入非数字就无限循环,好难啊,谁可以看看是什么问题吗?请在评论区告诉我,可以吗,同胞们,让我也感受一下C语言的魅力吧。
while循环里面是scanf,然后判断下是不是等于题目要求的那个,不是继续循环,否则break跳出循环
#include <stdio.h>
#include <string.h>
int main(){
int i;
char a[100];
while(1){
scanf("%s",a);
if(strcmp(a,"su1unjun")==0){
printf("you are right\n");
break;
}
printf("you are wrong\n");
}
}