Hello i would like to pass a struct to a variadic functions and use values inside the said struct in C. What i do not know how to do is how to access the contents of each struct that is passed.
Here is a example situation
typedef struct {
int num;
bool dontIncludeFlag;
} number;
int average(unsigned count, ...){
va_list ap;
int j;
int sum = 0;
va_start(ap, count);
for (j = 0; j < count; j++) {
if(va_arg(ap,number.dontIncludeFlag)) //This line does not work
sum += va_arg(ap.num, number); //so does this line
}
va_end(ap);
return sum / count;
}
int main(){
number a,b,c;
a.num= 5;
a.dontIncludeFlag = 0;
b.num= 2;
b.dontIncludeFlag= 1;
c.num= 1;
c.dontIncludeFlag= 0;
average(3,a,b,c);
}
How do i access the contents of the struct arguments i passed