fopen working then failing?

Started by
3 comments, last by ACAC 21 years ago
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?
Advertisement
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...
xp doesnt have a config.sys does it? heh
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.
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
You are not checking to see if fopen returned successfully. Is the return value of fopen NULL/EOF?

This topic is closed to new replies.

Advertisement