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, 1031👍, 0💬
Can you explain duplex contracts in WCF? In duplex contracts when client initiates an operation the ...
How To Export Your Connection Information to a File? - Oracle DBA FAQ - Introduction to Oracle SQL D...
What are the five levels in CMMI? There are five levels of the CMM. According to the SEI, Level 1 – ...
How To Empty Your Recycle Bin? - Oracle DBA FAQ - Managing Oracle Database Tables If your recycle bi...
What is AL.EXE and RESGEN.EXE? In the previous question you have seen how we can use resource files ...