Possible Duplicate:
determine size of dynamically allocated memory in c
I have a struct
in my c code, but this question is also valid for all other types so I will use int
instead of struct
I created.
int *a = realloc(NULL, 10*sizeof(int) );
printf("%d\n",sizeof(a)); //prints 4, needed to be 40
int b[10];
printf("%d\n",sizeof(b)); //prints 40
My question is this: I am using realloc
in my code and I don't know how I can find the total size of my array. What is the easiest way to do that? Thank you.