In another post link text
I am trying to do the same thing with a struct, but I have a problem with my sizeof operator, so in the integer case, I did this:
size_t totalMem = rows * sizeof(int *) + rows * cols * sizeof(int));
And in the struct case I did this:
size_t totalMem = (rows * sizeof(struct TEST *)) + (rows * cols * sizeof(struct TEST));
But I get the error: Invalid application of sizeof to incomplete type of struct TEST.
Any thoughts? Thanks.
Because you’re defining the struct as
you should always refer to the struct as
TEST, notstruct TEST, i.e. useTo use
struct TESTyou need to actually name the struct, i.e.You can allow both with