Advertisement

Variable Arguments

Started by July 07, 2000 12:36 AM
1 comment, last by zerwit 24 years, 5 months ago
I am trying to make a function that will have an interface like printf but I want to use the resulting string for my debugging stuff. I could use sprintf and pass the result, but it gets annoying to create a buffer and then call sprintf, and my debug function. My problem is that I don''t want to write a full function to do what sprintf does. Is there a way I can pass the whole argument list to sprintf. Or do you know of any other ways to do it. Thanks. *** Triality ***
*** Triality ***
    //: wrapper for logging messages to output device//: bool debugout(const char *msg, ...) {	va_list argList;	char buffer[512] = { 0 };	va_start(argList, msg);		vsprintf(buffer, msg, argList);	va_end(argList);	OutputDebugString(buffer);	OutputDebugString("\n");        //: could also send to file or other device	return false;}    


Then use just like your using sprintf/printf ...!

Advertisement
Thanks a lot I''ll try that out.

*** Triality ***
*** Triality ***

This topic is closed to new replies.

Advertisement