69,373
社区成员
发帖
与我相关
我的任务
分享
fseek(stdin,0L,2);//???
while(getchar()!='\n')
; //输入不是回车就执行空语句,然后继续循环,遇到回车循环终止
while(getchar()!='\n')
continue;
#include <stdio.h>
void main(void)
{
int ch ;
puts( "Input two or more chars. One is read now." );
ch = getchar();
putchar( ch );
putchar( '\n' );
puts( "The next char is taken from stdin." );
ch = getchar( );
putchar( ch );
putchar( '\n' );
rewind( stdin );
puts( "Input two or more chars. One is read now." );
ch = getchar();
putchar( ch );
putchar( '\n' );
rewind( stdin );
puts( "You must enter another char because of the rewind(stdin)" );
ch = getchar( );
putchar( ch );
putchar( '\n' );
}
#include <cstdio>
int main()
{
int c=0;
while ((c=getchar())!='\n') ;
printf("%d\n",c);// 10
printf("%c\n",c);// 输出换行
return 0;
}