首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

急问:关于ifstream中定位的有关问题

2012-02-08 
急问:关于ifstream中定位的问题为什么每次读到都是同一个字母?也就stream_buffer中的游标不往后走呢?是tel

急问:关于ifstream中定位的问题
为什么每次读到都是同一个字母?   也就stream_buffer中的游标不往后走呢?是tellg()的问题吗?

ifstream   infile.open( "1.txt ");
ifstream::pos_type   cur;
string   sentence;
char   word1;
while(infile> > word1)
{
sentence+=word1;
cur=infile.tellg();     //cur在是程序中是有用的,只是这里没显示
}

请达人指教,bow~

[解决办法]
ifstream infile;
infile.open( "1.txt ");
ifstream::pos_type cur;
string sentence;
char word1;
while(infile> > word1)
{
cout < <word1 < <endl;
sentence+=word1;
cur=infile.tellg(); //cur在是程序中是有用的,只是这里没显示
}
[解决办法]
ifstream infile( "test.txt ");
ifstream::pos_type cur;
string sentence;
char word1;
while(infile> > word1)
{
sentence+=word1;
cur=infile.tellg();
cout < <cur < <endl;
}
cout < <sentence < <endl;

木有问题 ~
[解决办法]
VC6?sp6补丁打了没有?
反正,无论如何,建议扔了VC6。
[解决办法]
是没有刷新缓冲区造成的吧
加了endl应该就行了

热点排行