Jump to content
  • Advertisement
Sign in to follow this  
Chett2001

File I/O problems

This topic is 4161 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,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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!