
例如:
#include
int
main(void)
{
char
c
c
=
getchar()
while(c!='
')//输入空格退出
{
printf("%c",
c)//这里改成你需要的那个函数做相应的工作就可以了
c
=
getchar()
}
return
0
}
#include<stdio.h>#include<ctype.h>
int main(void)
{
char gothere = 0
while(1)
{
printf("\ninput y continue,input n over.\n")
scanf("%c",&gothere)
getchar() //消除回车键,回车键也是一个字符,如果不消除下次默认输入回车键
if(!isalpha(gothere))
{
printf("error ,retry")
}
else
{
switch(gothere)
{
case 'y':
case 'Y':
printf("\nyou enter y , continue jisuan.\n")
break
case 'n':
case 'N':
printf("\nyou enter N , end the program\n")
return 0
break
default:
printf("\nyou enter an error word.retry\n")
break
}
}
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)