Hi,
I have a dynamic array which i need to find the size of to re-allocate more space to:
the sizeof(dynamic_array) always returns a vaule related to the wordsize, not the size of the allocated array.
How do i get this allocated size?
SD
I have a dynamic array which i need to find the size of to re-allocate more space to:
Code:
char **dynamic_array;
char *ptr;
ptr=(char *)malloc(10);
memcpy(ptr,"something\0",10);
dynamic_array=(char **)malloc(1);
dynamic_array[0]=ptr;
ptr=(char *)malloc(10);
memcpy(ptr,"nothing \0",10);
dynamic_array=(char **) _
realloc(dynamic_array,sizeof(dynamic_array)+1); /* ????? */
dynamic_array[1]=ptr;
the sizeof(dynamic_array) always returns a vaule related to the wordsize, not the size of the allocated array.
How do i get this allocated size?
SD