日期:2014-05-16  浏览次数:20579 次

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;
}
这样写看看。。。