I'm currently trying to get the length of a dynamically generated array. This is an array of structures:
typedef struct _my_data_ { unsigned int id; double latitude; double longitude; unsigned int content_len; char* name_dyn; char* descr_dyn; } mydata;
I initialize my array as follows:
mydata* arr = (mydata*) malloc(sizeof(mydata));
And then resized it with realloc and started populating it with data.
Then I tried to get its size using the code here .
sizeof(arr) / sizeof(arr[0])
This operation returns 0 , although my array contains two elements.
Can someone please tell me what I am doing wrong?
c
beta
source share