I want to pass a struct variable as a function parameter (sorry for bad English.) Here is what I want to do:
#include <stdio.h>
#include <stdint.h>
typedef struct {
int temp;
int hum;
int oxy;
} Data;
Data sens1;
Data sens2;
Data sens3;
sens1.temp = 5;
sens2.temp = 10;
sens3.temp = 15;
int ort(Data temp1 , Data temp2 , Data temp3)
{
int ort = ((temp1 + temp2 + temp3) / 3);
return ort;
}
int main(void)
{
printf("%d", ort(sens1.temp, sens2.temp, sens3.temp));
return 0;
}
How to add struct member called temp to function ort() as parameter?
Datastructures intemp1 + temp2 + temp3, that doesn't make sense (and won't compile). Please explain what theortfunction is supposed to do.