Hi Everyone
First post on this topic - so the place might be wrong but I can't see better - and I did not find a topic
on this matter.
System: XP
Processor: Intel
Using: Code::Blocks 8.0.2
Libs: Boost 1.41, Std
I came across a strange behavior that I thought was a misuse of C++ boost ifstream or compatibility issue with std ifstream
(although the first is inherited of the second).
The program I attached - works fine in a release / debug mode. It is fine as long as you
do not activate a step by steparound the fstream declaration (!) and subsequent use.
At the moment you do step by step in this piece of code - the debugger exit with status 1 :
since the release and the non step debug (you can step elsewhere than here) works.
I assume that would be a debugger issue.
Can someone test / double check / comment ?
if(boost::filesystem::exists(final))
{
// process file
try
{
boost::filesystem::ifstream _fileStream;
_fileStream.open(final);
cout << "Test: is file open" << endl;
if(_fileStream.is_open())
{
// keep going
while(!_fileStream.eof())
{
getline(_fileStream, _line);
// parse line - find "=" in the whole line to separate value
_position = _line.find_first_of('=');
// if found - i.e. not -1 == npos
if(_position != string::npos)
{
_key = _line.substr(0, _position); // from beginning to "="
_value = _line.substr(_position+1); // from "=" to end
cout << "Key is: " << _key << endl;
cout << "Value is: " << _value << endl;
} // else - don't bother - skip line
}
} else {
// exception here
cout << "File not opened" << endl;
}
} catch(...) {
cout << "prevented crash" << endl;
}
}
[attachment deleted by admin]