看一看getchar()起得作用?
#include<stdio.h>#include<stdlib.h>
void print()
{
printf("\n\t This is an example.\n\n You are welcome!\n\n");
}
main()
{
int flag=1;
char ch;
while(flag)
{
printf("\n Input 'F' or 'f' to start the program print,"
"\n other to exit:");
ch=getchar();
ch=toupper(ch);
getchar(); //去掉回车符.
if(ch=='F')
print();
else
flag=0;
}
getch();
}
哪位朋友帮忙解释一下:为什么getchar();起到去掉回车符的作用?谢谢!去掉以后好像没什么区别?