I cant understand this code.. Pls help..
Code:
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
int findmax(int, ...);
int main()
{
int max;
max = findmax(5, 23, 15, 1, 92, 50);
printf("maximum = %d\n", max);
max = findmax (3, 100, 300, 29);
printf("maximum = %d\n", max);
system("PAUSE");
return 0;
}
int findmax (int tot_num, ... ) // From here
{
int max, count, num;
va_list ptr;
va_start(ptr, tot_num);
max = va_arg(ptr, int);
for(count = 1; count < tot_num; count++)
{
num = va_arg(ptr, int);
if(num> max)
max = num; //especially this
}
return (max);
}