+ 1
If I have a pointer pointing to another pointer (both created with the function Malloc()). How can I free the memory?
Pointers in C
1 Antwort
0
just like 「HAPPY TO HELP」 to help you don't have to "it's unnecessary to allocate memory for a pointer that will just point to another allocated memory pointer" but you can still do this
int *ptr1 = malloc(sizeof(int) *3);
int *ptr2 = ptr1;
then you can free ptr1 from ptr2 since they both point to the same address
free(ptr2);
ptr2=NULL;