Memory allocation in C is usually done with malloc
.
frametable[i] = malloc(references * sizeof *frametable);
Alternatively, you could use calloc
:
frametable[i] = calloc(references, sizeof *frametable);
As you can see, the important part is determining the size of the memory allocation, and ideally you would use sizeof
of the variable you want to put it into. In this case, frametable
is of type char **
or a “pointer to pointers” an “array of pointers”. The sizeof *frametable
is used to determine the size of such a pointer.
2
solved How could I bring this code that is in C ++ to C? … it is important 🙁 [closed]