+ 5
How can I create a dynamic structure in C?
Lets say I have a system which can have any number of states which the user will specify and I need to store these states in a structure. struct states { char state1; char state2; : : }; How can I do that?
2 Réponses
+ 2
Such a thing isn't possible but maybe you're overthinking it.
If all your states are of type `char`, then you can save all of them in a big string (`char*`)!
+ 4
Schindlabua Actually yes, I am overthinking it 😅
But then, I have figured out that I should create just one structure and allocate it memory multiple times using malloc (This doesn't directly do what I want but I can manage)