首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

g++的有关问题,还是?不懂。

2012-02-12 
g++的问题,还是?不懂。。。#include iostream#include fstream#include stringusingnamespacestdintma

g++的问题,还是?不懂。。。
#include <iostream>
#include <fstream>
#include <string>

using   namespace   std;

int   main()
{
ifstream   out( "t.txt ");
string   line;
int   i   =   0;
while(1)
{
if(out.eof())
break;
out   > >   line   ;
cout   < <   line   < <   "   ";

}//while(!out.eof());

return   0;
}

t.txt   内容为Hello,world!   I   hope   I   can   succeed!
输出却为Hello,world!   I   hope   I   can   succeed!   succeed!(succeed重复了两次!)
在dev_c++却输出正常。。。
问了几个人,他们的g++都运行正确,为什么?
这问题可以怎么解决呢?

谢谢!

[解决办法]
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
ifstream out( "t.txt ");
string line;
int i = 0;
while(!out.eof()))
{
out > > line ;
cout < < line < < " ";
}
return 0;
}
这样写看看。。。

热点排行