Struct Foo{ char *pName; char *pAddress;};main(){ struct Foo *obj = malloc(sizeof(struct Foo));clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress);}
A) Your Name Your Name
B) Your Address, Your Address
C) Your Name, Your Address
D) None of the above
Explanation: Prints Nothing, as after free(obj), no memory is there containing obj->pName & pbj->pAddress
-
Interview Candidate
- Dec 10th, 2005
- 2
- 5822
Showing Answers 1 - 2 of 2 Answers
Related Answered Questions
Related Open Questions
Struct Foo{ char *pName; char *pAddress;};main(){ struct Foo *obj = malloc(sizeof(struct Foo));clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress);}
B) Your Address, Your Address
C) Your Name, Your Address
D) None of the above
Explanation: Prints Nothing, as after free(obj), no memory is there containing obj->pName & pbj->pAddress
Related Answered Questions
Related Open Questions