void fun2(char *format, ...){
va_list arg_list;
va_start(arg_list, format);
vprintf(format, arg_list);
va_end(arg_list);
}
void fun1(char *format, ...){
fun2(format);
}
int main(){
fun1("test: %d", 100);
}
Output:
test: 100
https://onlinegdb.com/OfdDeSJg_
Does the above example have something wrong or not recommended?
I guess that when the fun2(format); call is made, only the pointer to the first parameter (format) is passed, is that correct?
When vprintf in fun2 accesses the integer 100, where is this integer? in the stack reserved for fun1, in the stack reserved for fun2, in the stack reserved for vprintf, or somewhere else?
If as I imagine only the pointer to the first parameter is passed to fun2, does this mean that when the functions and macros called by fun2 access the integer 100 they are accessing the stack reserved for fun1?