Sign in to follow this  

File I/O problems

This topic is 3851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, ive this function in a DirectX application:
void ReadBookmarkContent()
{
	
	int i=0;
	
	std::fstream fBookmarkInfo(books\\bookmarks.txt");

	{
	for(i=0;!fBookmarkInfo.eof();i++)
	{
	fBookmarkInfo.getline(cBookmarkInfo[i],200,'*'); //taking in the file contents
	}
	fBookmarkInfo.close();
	}	
}
Everything compiles correctly but when it comes to runtime i get this error: Image Hosted by ImageShack.us Anyone got a idea why it happens? ive got a very similar function to this in another place that works fine. the character array is defined as: char cBookmarkInfo[40][200]; Which is a global variable, Further info the error, it occurs here in istream:
_CATCH_IO_END
			}

	---->	*_Str = _Elem();	// add terminating null character
		_Myios::setstate(_Chcount == 0 ? _State | ios_base::failbit : _State);
		return (*this);
		}
And call stack says:
>	msvcp80d.dll!std::basic_istream<char,std::char_traits<char> >::getline(char * _Str=0x0093c188, int _Count=200, char _Delim='*')  Line 648 + 0x3 bytes	C++
:O, thanks for your help Chett

Share this post


Link to post
Share on other sites
You want to know what the problem was? I wrote the file name as bookmark.txt and it was allready a txt format so the real file name was bookmark.txt.txt, and this got me so fustrated last night lol.

Thanks for the help,
Chett

Share this post


Link to post
Share on other sites
Hehe. Any programmer should have Windows show file extensions. FYI, open a folder then go to Tools->Folder Options->View Then uncheck 'Hide extensions for known file types'. No more of that problem!

But as thallish said, you should probably assert or something that the file is open.

Share this post


Link to post
Share on other sites

This topic is 3851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this