Converting a argc / argv construct into a va_list
Hi
I'm new here, so appologies for my first post being a request!!
I was wondering if anyone can help, I want to write a piece of code that converts an argc / argv to a variable argument list.
Basically I want to do something like the following
Code:
void
print_args(int argc, char *argv[])
// first arg fmt string, subsequent args
{
if(argc == 1)
printf(argv[1]); // assumes nothing to be substituted
else if (argc == 2)
printf(argv[1], argv[2]) ;
else if (argc == 3)
printf(argv[1], argv[2], argv[3]) ;
// etc.
}
Unfortunatly I need to stick with argc / argv prototype
What I was wondering is if I could write something to create a va_list and call vprintf?
Anyone know if this is possible?
Thanks in advance
Craig