Message Box with printf capability
Posted
by Christian Skovdal Andersen
on August 6th, 1998
Example:
int MsgBox(UINT nType, PSTR sz,...)
{
char ach[512];
va_list args;
va_start(args, sz);
wvsprintf (ach, sz, args); /* Format the string */
int retval = AfxMessageBox (ach, nType == 0 ? MB_OK|MB_ICONEXCLAMATION : nType);
return retval;
}
void main(int argc, char *argv[])
{
MsgBox(MB_OK|MB_ICONINFORMATION, "There are %ld commandline parameters - parameter one is %s", argc, argv[1]);
}
Last updated: 15 May 1998

Comments
You forgot to call va_end()
Posted by Passmaster on 03/25/2004 04:15pmuse _vsnprintf
Posted by Legacy on 07/22/1999 12:00amOriginally posted by: Olan Patrick Barnes
If you aren't worried about portability, Microsoft VC has _vsnprintf which allows you to detrmine the max # of characters to put into the string. vsprintf and sprintf and the like do no error checking to see if they have spilled over the buffer size, which if it does will crash your program.
Replyreplace wvsprintf with vsprintf
Posted by Legacy on 04/11/1999 12:00amOriginally posted by: XuYifeng
wvsprintf does not support float and double,
Replycan you replace wvsprintf with vsprintf ?