so I currently have a structure that looks like this:
typedef struct example {
bool arr[];
} example_t;
I also have a create function that looks like this:
example_t *newExample(int SIZE){
example_t *example = malloc(sizeof(example_t));
example->arr = ???
return example;
}
And from this, I could do something like:
example_t *example = newExample(MAX);
if ( example->arr[10] )
....
Is it possible in C to create an array with a variable size logical elements?
For reference: I need to somehow match the integers either with char*or with bool, so I can call arr[num]and get either a string / word, or the value true / false. In both cases, I'm not sure how to declare, and then initialized to a variable size. Thanks in advance!
source
share