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; }
3 Answers
0
It gives different values ! <DD>