typedef struct Expected {
const int number;
const char operand;
} Expected;
Expected array[1];
Expected e = {1, 'c'};
array[0] = e;
I don't understand why you cannot add to a struct array like that. Do I have to calculate the positions in memory myself?
The element of Expected
are declared const
. That means they can't be modified.
In order to set the values, you need to initialize them at the time the variable is defined:
Expected array[1] = { {1, 'c'} };
The fact that you're using an array doesn't matter in this case.
Making the struct members const
means you can't write to them.
After removing that it works.
typedef struct Expected {
int number;
char operand;
} Expected;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With