69,371
社区成员
发帖
与我相关
我的任务
分享
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
void print()
{
printf("\n\t This is an example.\n\n\t You are welcome!!\n\n");
}
int main (void)
{
int flag=1;
char ch;
while(flag)
{
printf("\n Input'F'or'f'to start the program print,\n othet to exit:");
ch=getchar();
ch=toupper(ch);
while(getchar() != '\n') //这么用就是了,把缓冲区里面的一行输入的剩下的都给剔除了
; //这个getchar();在这里有什么作用,请各位高手帮我解释一下。
if(ch=='F')
print();
else
flag=0;
}
return 0;
}
这个getchar();在这里有什么作用,请各位高手帮我解释一下。
回收回车符!