标签:default include continue enter
#include <stdio.h>
#include <ctype.h>
int main(int argc,char **argv)
{
char ch;
printf("Enter the want you want:\n");
while((ch = getchar()) != ‘#‘)
{
if(ch == ‘\n‘)
continue; //改成break的话,直接回车就会跳出循环。
if(islower(ch))
switch(ch)
{
case ‘a‘:puts("a");break;
case ‘b‘:puts("b");break;
case ‘c‘:puts("c");break;
case ‘d‘:puts("d");break;
default:printf("gameover.\n");
}
else
printf("simple.\n");
while(getchar() != ‘\n‘) //很经典的清空输入行
continue;
printf("try again.\n");
}
printf("bye.\n");
return 0;
}本文出自 “天才的实力” 博客,请务必保留此出处http://8299474.blog.51cto.com/8289474/1580306
标签:default include continue enter
原文地址:http://8299474.blog.51cto.com/8289474/1580306