Hello,
I've been looking for a way in C to do something like this :
I only require this to work on an array of strings. I've read that trying to build a va_list is somewhat close to black magic since it's machine dependent. I've been able to have a look at the va_list memory and been able to find back arguments in it with a real va_list function like :
It's not that difficult to understand how it works, but since I need this to be portable and fast. It's a bit out of my current knowledge of C. There's always the "lame" version that would do something like
and to process this through a
But since I don't know how many arguments I would get in the array of args, there's always some kind of drawback.
Any advice please?
I've been looking for a way in C to do something like this :
Code:
char *args[] = { "arg1", "arg2", "arg3", NULL };
somefunc("%s %s %s", args);
I only require this to work on an array of strings. I've read that trying to build a va_list is somewhat close to black magic since it's machine dependent. I've been able to have a look at the va_list memory and been able to find back arguments in it with a real va_list function like :
Code:
somefunc("%s %s %s", "arg1", "arg2", "arg3", NULL);
It's not that difficult to understand how it works, but since I need this to be portable and fast. It's a bit out of my current knowledge of C. There's always the "lame" version that would do something like
Code:
somefunc("%s %s %s", args, count);
and to process this through a
Code:
switch(count) {
case 1: printf(fmt, args[0]); break;
...
}
But since I don't know how many arguments I would get in the array of args, there's always some kind of drawback.
Any advice please?