+ 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

4th Feb 2020, 6:41 AM
Carlos Caminero
1 Odpowiedź
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;
4th Feb 2020, 7:16 AM
✳AsterisK✳
✳AsterisK✳ - avatar