Ok, so how to explain this easy?
Well I have a function that takes a char* and a va_list as arguments.
It will then send the complete, processed string to another function.
Example:
Code:
void function(char *txt, va_list args)
{
/* the char way
* problem: don't know the length of txt + arguments
*/
char *string1 = malloc(???);
vsprintf(string1, txt, args);
another_function(string1);
/* the string way
* problem: don't know how to use it with vsprintf()
*/
string string2;
???
another_function(string2.c_str());
}
void another_function(char *txt)
{
printf("I got: %s\n", txt);
}
So, two ways to go:
1) Use char* with malloc. I need to know how long the complete string will be to avoid having to chop it.
2) Use string. But can I use it with a va_list?