while (1){
scanf("%c", &input);
if((input>='a')&&(input<='z')) {
count[input-'a']++;
}
else if((input>='A')&&(input<='Z')) {
count[input-'A']++;
}
else {
break;
}
}
为什么该命令一次获得一个值? while(1)代表无限循环吗?
break
causes the loop to break thus not running again.Remove it so the
while
loop will occur again.break
exit awhile
whatever the condition in thewhile
.You did not show what you input in the question. However according to the behaviour you observe, it's not a letter or a uppercase letter, thus you end up breaking the
while
.