while与switch嵌套,利用break跳出switch结构后,重新进行while循环,welcome函数被调用两次,如何删去重复输出,求解
getchar() 和 scanf("%c", &ch); 会读取任意的字符,包括 '\n'换行字符
如果缓存区中遗留了'\n'就会被getchar() 和 scanf("%c", &ch); 读取。
可以在getchar()之前用 setbuf(stdin, NULL); 清除输入缓存
setbuf(stdin, NULL); //清除输入缓存
ch = getchar();
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!
getchar影响了,参考
https://blog.csdn.net/RyanLee90/article/details/118606062