Hi,
I want to write a log function but I want to implement in the style of fprintf/sprintf style. ie
fprintf(arg1, template string, template values)
write_to_log(template string, some array of ints/double etc to fill the template)
I want to implement this variadic function:
void write_to_log(char template, int nargs, ...)
{
printf(template, ???);
}
int main()
{
write_to_log("client speed: %d\n", 1, 5);
}
I am stuck at line 3 where I want to do pass to printf whatever variable array of argument is passed to write_to_log.
What should I pass to printf inside write_to_log?
Besides
a) how to handle a mix of different types ie int / float etc just like printf?
b) how to handle string?
Thanks.