急问:关于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应该就行了