Advertisement

Writeing A Text File

Started by November 06, 2000 09:29 PM
2 comments, last by Galileo430 24 years, 2 months ago
I am going out of my mind. I can''t get this file access to work. It should work, unless I missed something.
    
// GLOBALS=======================================================

BOOL		firstopen;

// FUNCTIONS=====================================================

void DebugOut (char *string)
{
	//---------Locals---------//

	FILE *stream;
	//------------------------//

	if (firstopen = TRUE)
	{
		stream = fopen("debug.txt", "wt");
	}
	else if (firstopen = FALSE)
	{
		stream = fopen("debug.txt", "w+t");
	}

	fprintf(stream, "%s\n", string);

	if (firstopen = TRUE)
	{
		firstopen = FALSE;
	}
	fclose(stream);
}
    
All it does is write over the first line. I can''t get it to write on the next line.
------------------------------------------------------------I wrote the best video game ever, then I woke up...
it might be because your testing statements have the assignment operator instead of the equality operator.
i.e.
if (firstopen = TRUE)
instead of
if (firstopen == TRUE)

try replacing the = with == and see if that works.
Advertisement
Nope..
------------------------------------------------------------I wrote the best video game ever, then I woke up...
Try using ''a'' instead of ''w''. That''ll have it append everything you write to the end... not sure if that''s what you want.



-Agent1



Encrypted Transmission from Flagg, sent Tue Sep 19, 2000 4:45 PM:
hehe... we''re gonna have to change our number to unlisted...

This topic is closed to new replies.

Advertisement