Hi!
How can it be that ifstream::ftell() alters the read position?!
I''m using VC++ and ifstream not std::ifstream.
while(...)
{
infile.ftell();
infile.getline(buffer,200);
// Process buffer data
}
is NOT the same as
while(...)
{
infile.getline(buffer,200);
// Process buffer data
}
The thing is that getline() reads one byte too much somtimes if ftell is there.
Any thoughts?
quote:Original post by Javelin
How can it be that ifstream::ftell() alters the read position?!
I''m using VC++ and ifstream not std::ifstream.
Eh?! i don''t know what you mean by "ifstream not std::ifstream".
and ifstream has no ftell. there is a tellg(), however...
yes sorry... meant tellg()
I''m not using the ifstream in namespace std.
// Javelin
-- Why do something today when you can do it tomorrow... --
I''m not using the ifstream in namespace std.
// Javelin
-- Why do something today when you can do it tomorrow... --
quote:Original post by Javelin
I''m not using the ifstream in namespace std.
Then nobody can help you.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
hmmz... well
I think most ppl using MSVC++ do not use the std:: version of the streams... If you want to use the std:: versions you have to type it explicit.
E.g.
std::ifstream infile;
using namespace std;
or
using std::ofstream;
I worked around the problem by using a binary reading of the file instead, but that''s not a very neat solution though.
I do not know if it''s a bug in the MSVC++ libraries... but the ifstream::tellg() actually alters the reading position in the file.
// Javelin
-- Why do something today when you can do it tomorrow... --
I think most ppl using MSVC++ do not use the std:: version of the streams... If you want to use the std:: versions you have to type it explicit.
E.g.
std::ifstream infile;
using namespace std;
or
using std::ofstream;
I worked around the problem by using a binary reading of the file instead, but that''s not a very neat solution though.
I do not know if it''s a bug in the MSVC++ libraries... but the ifstream::tellg() actually alters the reading position in the file.
// Javelin
-- Why do something today when you can do it tomorrow... --
I think most ppl using MSVC++ do not use the std:: version of the streams... If you want to use the std:: versions you have to type it explicit.
Then most people using MSVC++ learned C++ improperly. <iostream.h> and <fstream.h> are not standard C++ library headers.
I do not know if it''s a bug in the MSVC++ libraries... but the ifstream::tellg() actually alters the reading position in the file.
Since the ifstream class that is not in the std namespace is old and non-standard there is absolutely no telling what the problem might be. Since there is no specification for what ifstream::tellg should do, ifstream::tellg could do just about anything, including modifying the get pointer''s position.
Which is why people should use standard C++ classes, like std::ifstream
Additionally - MSVC6''s library is buggy, see link in sig.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
Then most people using MSVC++ learned C++ improperly. <iostream.h> and <fstream.h> are not standard C++ library headers.
I do not know if it''s a bug in the MSVC++ libraries... but the ifstream::tellg() actually alters the reading position in the file.
Since the ifstream class that is not in the std namespace is old and non-standard there is absolutely no telling what the problem might be. Since there is no specification for what ifstream::tellg should do, ifstream::tellg could do just about anything, including modifying the get pointer''s position.
Which is why people should use standard C++ classes, like std::ifstream
Additionally - MSVC6''s library is buggy, see link in sig.
[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement