How can I write a function that takes a format string and a variable number of arguments
How can I write a function that takes a format string and a variable number of arguments, like printf, and passes them to printf to do most of the work?
Use vprintf, vfprintf, or vsprintf. These routines are like their counterparts printf, fprintf, and sprintf, except that instead of a variable-length argument list, they accept a single va_list pointer.
As an example, here is an error function which prints an error message, preceded by the string ``error: '' and terminated with a newline:
void error(const char *fmt, ...)
fprintf(stderr, "error: ");
vfprintf(stderr, fmt, argp);
fprintf(stderr, "\n"); }
2015-06-12, 957👍, 0💬
What Happens If One Row Has Missing Columns? - XHTML 1.0 Tutorials - Understanding Tables and Table ...
What does XmlValidatingReader class do? XmlTextReader class does not validate the contents of an XML...
How To Enter Boolean Values in SQL Statements? - MySQL FAQs - Introduction to SQL Basics If you want...
How was XML handled during COM times? During COM it was done by using MSXML 4.0. So old languages li...
What is a measure in OLAP ? Measures are the key performance indicator that you want to evaluate. To...