There is a memory management issue in the following main function. Please explain the memory management issues
Fantastic news! We've Found the answer you've been seeking!
Question:
There is a memory management issue in the following main function. Please explain the memory management issues in this code and explain the reason behind this.
int main(){ char *p1 = malloc(20); char *p2 = malloc(30); strcpy(p1, "cat"); p2 = p1; printf("%s", p1); free(p1); free(p2); return 0;}
Related Book For
Posted Date: