Hello I have the following code:
struct temperatures_t { char lowTempSetting = 18; char highTempSetting = 26; char currentTemp = 23; }; struct runningState_t { struct temperatures_t temperatures; }; struct runningState_t runningState; void test(runningState_t *runningStateVar) { runningStateVar->temperatures->lowTempSetting++; runningStateVar->temperatures->currentTemp = 10; printf(runningStateVar.temperatures.lowTempSetting); } void main() { test(&runningState); } But getting the following error on the runningState->temperatures-> lines:
{ "message": "operator -> or ->* applied to \"temperatures_t\" instead of to a pointer type" } I have also tried variations:
&(runningState)->temperatures->lowTempSetting++; And other variations based off what I saw in this answer: C pass a nested structure within a structure to a function?
But without much luck
printfcall is wrong as well.int8_tinstead. Or just use plainint.structkeyword when declaring variables, as the structure tag-name is a type-name similar to e.g.int. And don't useprintfto print butstd::cout.int8_tsince it's usually based onchar, which means when you print it withstd::coutand<<it will be printed as a characters not a small integer. Use plaininteven for small integers. And do input-validation to make sure that users don't enter invalid or out-of-range values.