I wanted to dynamically allocate a partially fixed size array, but ran into errors which would lead me to believe I don't actually know how an array like this functions, so I'm trying to figure out how would you dynamically allocate in this case? Basically I'm asking how to do what's done in this question, Initialization of 2D array with dynamic number of rows and fixed number of columns. C++ but in pure C.
char *list[256];
int len = 10;
list = (char **) calloc(len, 256);
This is the code I have right now, but I'm getting this error: "error: assignment to expression with array type". Thanks.
Maybe you're looking for something like this:
Output:
Here, I'm using a typedef to define a a row with a fixed number of columns and use that to create an array with a variable number of rows