Question: Given the following C code and assuming all necessary preprocessor statements and libraries are included. 1 . char * str 1 ; 2 . char

Given the following C code and assuming all necessary preprocessor statements and libraries are included.
1.char *str1;
2.char *str2;
3.char *str3;
4.str1= malloc(sizeof(char)*10);
5.str2= malloc(sizeof(char)*10);
6.if(str1!= NULL)
7. strcpy(str1, "Holidays");
8.if(str2!= NULL)
9. strcpy(str2, "Final Exam");
10. if(str3!= NULL)
11. strcpy(str3, "Programming");
12. str3= str1;
13. str2= str3;
14. str1= str2;
15. free(str1);
16. free(str2);
17. free(str3);
Check the following line numbers of where a memory management error can potentially occur.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!