Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tedz2usa/b34993a6a29abb74670bad8916a0571c to your computer and use it in GitHub Desktop.
Save tedz2usa/b34993a6a29abb74670bad8916a0571c to your computer and use it in GitHub Desktop.
http://stackoverflow.com/questions/1056411/how-to-pass-variable-number-of-arguments-to-printf-sprintf
void Error(const char* format, ...)
{
va_list argptr;
va_start(argptr, format);
vfprintf(stderr, format, argptr);
va_end(argptr);
}
If you want to manipulate the string before you display it and really do need it stored in a buffer first, please please please use vsnprintf instead of vsprintf. vsnprintf will prevent an accidental buffer overflow error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment