Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ACAC

fopen working then failing?

This topic is 5540 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

Okay Ive been working on a tile system and its now time to make an editor, Ive got this logger which logs errors, now its never failed before but now for some reason while using MFC it is doing wierd stuff, i was wondering if anyone could tell me that it could be a clash in the mfc code and mine? or its just a wierd error?, anyways heres the code
  
//======================================//

// Prints a formatted message to the file

//======================================//

void CLog::Print(char *text, ...)
{
	char buffer[256];
	
	//clear buffer

	memset(buffer,''\0'',256);

	// Combine args with the string

	va_list args;
	va_start(args, text);
	vsprintf(buffer, text, args);
	va_end(args);


	m_File = fopen(m_Filename,"a+");

	fprintf(m_File,buffer);

	fprintf(m_File,"\n");

	fclose(m_File);
}
  
Okay, Now ive stepped though it in the debugger several times, the first call to that function succeeds and the second doesnt. fopen fails on the second call. m_Filename never changes, and buffer is of a valid length < 256, ive also tried a and a+ for the file open settings. Heh anyone?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I had a similar problem with a school project some time ago, I had to look in the config.sys file and see how many files and buffers I had available, turns out I only increased the file''s number and it stop having problems, maybe you could try it...

Share this post


Link to post
Share on other sites
quote:
Original post by ACAC
xp doesnt have a config.sys does it? heh


No, but it does have environment variables and the like, which is effectively the same.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!