Advertisement

Game programming tutorial 5 question

Started by June 30, 2002 02:38 PM
0 comments, last by Sketchy 22 years, 8 months ago
Hey, In tutorial 5, SK has a LOG class, and, um, I''m not sure what the heck ... is and va_list, I can''t find any examples in the code where his variable arguments are used. Any help would be great.
  

bool LOG::
	Output(char* text, ...)
	{
	va_list arg_list;

	//Initialize variable argument list

	va_start(arg_list, text);

	//Open the log file for append

	if((logfile = fopen("Shining3D.log", "a+"))==NULL)
		return false;

	//Write the text and a newline

	vfprintf(logfile, text, arg_list);
	putc(''\n'', logfile);

	//Close the file

	fclose(logfile);
	va_end(arg_list);

	return true;
	}

  
With the va stuff you can use the function like printf and sprintf. You can do stuff like this :

log.OUTPUT("the value is %i",some_value);

which is real handy if you wanna write the values of variables to the log file.





[edited by - George2 on June 30, 2002 3:48:21 PM]
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon

This topic is closed to new replies.

Advertisement