0

variadic func.

in a function like this int max(int count,...) { va_list counter; int max = va_arg(counter,int); va_start(counter,count); for(int i=1;i<count;i++){ int temp = va_arg(counter,int); if (max<temp) max =temp;} va_end(counter); return max; } why i had to add ""int temp = va_arg(counter,int);"" into the for loop to make the code work ? why i couldnt just say that int max(int count,...) { va_list counter; int max = va_arg(counter,int); va_start(counter,count); for(int i=1;i<count;i++){ if (max<va_arg(counter,int)) max =va_arg(counter,int);} va_end(counter); return max; }

17th Nov 2022, 1:51 PM
Shimaa
Shimaa - avatar
1 Respuesta
0
It gives different values ! <DD>
19th Nov 2022, 10:32 PM
Shimaa
Shimaa - avatar