iostream 和 iostream.h中用ctrl+z的不同

topc0o0der 2009-09-20 05:00:08
#include <iostream>
using namespace std;

int main()
{
int t=1;
while(cin>>t);
cout<<"end"<<endl;
return 0;
}
///////////////////////////////////////////
#include <iostream.h>

int main()
{
int t=1;
while(cin>>t);
cout<<"end"<<endl;
return 0;
}
上面的程序当第一次输入ctrl+z时,没有反应。第二次用ctrl+z时才退出;
下面的一次就推出,这是为啥呢?
...全文
56 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
topc0o0der 2009-09-20
  • 打赏
  • 举报
回复
我换成dev就行了,二楼是对的。
starcat 2009-09-20
  • 打赏
  • 举报
回复 1
  There are currently two versions of the C++ object-oriented I/O library in use: the older one that is based upon the original specifications for C++ and the newer one defined by Standard C++. The old I/O library is supported by the header file <iostream.h>. The new I/O library is supported by the header <iostream>. For the most part, the two libraries appear the same to the programmer. This is because the new I/O library is, in essence, simply an updated and improved version of the old one. In fact, the vast majority of differences between the two occur beneath the surface, in the way that the libraries are implemented—not in how they are used.
  From the programmer’s perspective, there are two main differences between the old and new C++ I/O libraries. First, the new I/O library contains a few additional features and defines some new data types. Thus, the new I/O library is essentially a superset of the old one. Nearly all programs originally written for the old library will compile without substantive changes when the new library is used. Second, the old-style I/O library was in the global namespace. The new-style library is in the std namespace.

就怕楼主没耐心看下去。。。
  • 打赏
  • 举报
回复
呃,第一个代码是正确的,是VC6的问题导致了第一次没反应。第二次回车一下即可
第二个代码有误,在新一些的编译器上无法编译。

最好升级到VS2008
老邓 2009-09-20
  • 打赏
  • 举报
回复
库的实现不同。
iostream.h是非标准的,别用了。

64,642

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧