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, 899👍, 0💬
If locking is not implemented what issues can occur? IFollowing are the problems that occur if you d...
Does there exist any other function which can be used to convert an integer or a float to a string? ...
How To Return the Second 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If yo...
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
How Many Types of Tables Supported by Oracle? - Oracle DBA FAQ - Managing Oracle Database Tables Ora...