My program writes to a log and to stdout. Every message, however, has a certain priority and the user specifies in Preferences which priorities go to which stream (log or stdout
You want to call vprintf() instead of printf() using the variable arguments "varargs" capabilities of C.
#include
int write_log(int priority, const char *format, ...)
{
va_list args;
va_start(args, format);
if(priority & PRIO_LOG)
vprintf(format, args);
va_end(args);
}
For more information, see something along the lines of this.