Question

I'm getting the error expression "expected expression before char"

char *set_buffer(char *buf, int num_str, ...) { 
    va_list args;
    va_start(args, num_str); 
    for (int i = 0, offset = 0; i < num_str; ++i) {
         char *str = va_args(args, char *); // error here
         offset += snprintf(buf+offset, strlen(str), str); 
    }
    va_end(args);
}

Anybody have any idea why?c

Was it helpful?

Solution

The macro is va_arg not va_args

char *str = va_arg(args, char *)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top