for some reason, i cant get this working:
void examplefunctionname(string str, ...){
...
va_start(ap, str.c_str());
nor do i get this work:
void examplefunctionname(string str, ...){
...
int len = str.length();
char *strlol = new char[len+1];
for(int i = 0; i < len; i++){
strlol[i] = str[i];
}
strlol[len] = 0;
va_start(ap, strlol);
but this does:
void examplefunctionname(const char *str, ...){
...
va_start(ap, str);
could someone show me how i can use string instead of const char * there?
its outputting random numbers when i call examplefunctionname("%d %d %d", 1337, 1337, 1337)
From the documentation:
You’ve done this correctly in your working example:
va_start(ap, str), andstris the last known argument. But in the other two examples, you’re passing odd things tova_start.