Re: Strange File I problem.
I think your problem is here:
Quote:
Originally Posted by
Matt000r000
Code:
for (int i=0; !isCalendar(str)&&!file.eof(); i++) {
file>>str;
cout<<str<<' ';
}
Have a look at this FAQ.
Quote:
Originally Posted by
Matt000r000
I have also found, in my old-fashioned way of commenting out code and experimenting, that if you comment out the isCalendar() function like so:
Code:
if (str[7]=='r') {
//if ((int)str[8]==0) {
return true;
//}
}
... then the program runs fine.
That's probably because the function now returns true where it previously returned false. Hence, your loop is ended before you reach the end of the file.
Re: Strange File I problem.
Also, I think you are making the serach more difficult than it needs to be:
Code:
std::string word;
bool bFound = false;
while ( !bFound && (file>>word) )
{
if (word == "Calendar")
bFound = true;
}
if (bFound)
{
cout << "found .. rest of line = ";
getline(file,word);
cout << word << "\n";
}
Re: Strange File I problem.
Did you step through it with the debugger?
The debugger wil tell you exactly what line it's broken on.