VA_List write string

Hi I'm relatively new to programming C++ and I'm writing a wrapper around this class we have. What I like to do is take a string like "%s %s" and use a va_list to fill the values in like a printf does the difference is that my method writes to a text file. The WriteString method needs to be used because it handles Unicode. So essentially the text variable needs the fully formatted string before I write to the file and I'm not sure how to do this. Thanks, I appreciate any help.

int CTextFile::FormatString(CString text, ...)
{
va_list ap;
va_start(ap, text);
this->WriteString(text);
va_end(ap);

return 0;
}

thanks,
Robert
Did you look at vfprintf? Did you look at boost::format? Do one of these fit what you need?
I was able to get it to work using the FormatV method in CString. Thanks for the help though.

int CTextFile::FormatString(CString text, ...)
{
CString fString;
va_list ap;
va_start(ap, text);
fString.FormatV(text, ap);
this->WriteString(fString);
va_end(ap);

return 0;
}

Robert
Topic archived. No new replies allowed.