Originally Posted by
eXcellion
In our book it is used as follows:
Code:
int** a;
a = (int**)calloc(5,sizeof(int*))
I do know how to program in C, or I'm learning it, atleast..
So instead of just criticizing my, clearly wrong attempt, you could perhaps guide me in the right direction?
I see this all the time and for C it's wrong... for C++ it's right. Be careful of this.
Should be...
Code:
a = calloc(5,sizeof(int*));
//or if allocating an int* instead of an int**
a = calloc(5,sizeof(int));
In C calloc(), malloc() and realloc() return void* which can be assigned to any pointer.
For the actual problematic code line...
Code:
dict->features = (dict->features)calloc(aantal,sizeof(dict->features));
// should be
dict->featuers = calloc(aantal,sizeof(features));
This because you are making space for the struct itself, not a pointer to the struct.