I have nested structs and I'm having trouble assigning values to the inner struct in different functions. My structs are defined as:
typedef struct {
double reading;
float readingTime;
int readingNum;
} Measurement;
typedef struct {
Measurement vref;
Measurement vout;
Measurement voutShort;
} Unit;
In the function (measureUnit()) where I declare Unit unit;I call takeMeasurement(unit) (which I simplified for clarity below) and where I try to assign values to some values in the inner Measurement struct :
takeMeasurement(Unit unit){
int readingNum = 42;
unit.vout.readingNum = readingNum;
}
When I then try to access these values in printData(Unit unit) which is called from measureUnit(),
`printf("%i", unit.vout.readingNum)`
always prints 0.
Shouldn't these values "follow" unit around through different functions?