1.我疑惑了
char a[20]; while(scanf("%s",a)!=EOF){ cout<<"hello"<<endl; }
为什么要按两下ctrl+z 才能结束呢??
2.小插曲
教你怎么用EOF结束程序:
scanf("%c%c%c"a,b,c); if('a'=='E'&&'b'=='O'&&'c'=='F') return 0;
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
问题算是找到答案了!
摘自
当以%s输入字符串时需要按两次(ctrl+z)才能退出!!
当以%d输入数字是一次(ctrl+z)就可以退出了
提问者采纳
这是vc6的 bug,因为getchar无此问题,%d无此问题,gcc无此问题。。。。 一个类似的bug(微软已经确认):http://bbs.linuxpk.com/home-space-uid-3973-do-blog-id-11952.html可以参考下。。。
- 提问者评价
-
谢谢!