要求输入一个是字母,然后如果输入错误提示重新输入,如果输入 a s m d q 以外的东西,提示重新输入。
我把代码复制到这里,还请各位大神帮忙。
代码:
char get_ch(void)
{
char get_word;
while (!isalpha(get_word = getchar())) /*|| (get_word == 'a' || get_word!= 's' || get_word!='m' ||get_word!= 'd'||get_word!= 'q'))*/ 这里出现问题,我已经用注释
{
printf("Your input is incorrect, please input:\n");
printf("a. add \t\t s. substract\n");
printf("m. multiply\t d. divide\n");
printf("q. quit\n");
printf("Please enter your operation of your choice:\n");
while (getchar()!= '\n')
continue;
}
return get_word;
}