以下是引用aneeg在2014-4-22 18:53:01的发言:
我当然知道EOF和"\n"不是同一个字符,这结果不是我想要的
我当然知道EOF和"\n"不是同一个字符,这结果不是我想要的
你从来就没说你到底想干吗 一直是大伙在猜

DO IT YOURSELF !

2014-04-22 20:51

2014-04-24 02:10
2014-04-25 01:03
程序代码:
#include<stdio.h>
int main(void)
{
while(getchar()!='\n') //这里\n只能使用单引号,而且必须用单引号.否则报错.
printf("中华人民共和国\n");
return 0;
}

2014-04-25 06:12
2014-04-26 03:30
程序代码:#include<stdio.h>
int main(void)
{
while(getchar()!='eof'){
printf("中华人民和国\n") ;
while(getchar()!='\n')
break;
}
return 0;
}
2014-04-26 07:38

2014-04-26 11:57
while(getchar()!='eof'), 而getchar()一次只接收一个字符,因此首先检查a!='EOF',于是执行
printf("中华人民和国\n") ;while(getchar()!='\n')
while(getchar()!='\n')这个循环.

2014-04-26 12:23

2014-04-26 12:50