Output of these programs.

Code
  1. span style="color: #ff0000;">"Your Name""%s", obj->pName);

  2. }

  3.  
Copyright GeekInterview.com

a. Your Name

b. compile error

c. Name

d. Runtime error


Code
  1. span style="color: #ff0000;">"Your Name");

  2. strcpy(obj->pAddress, "Your Address""%s""%s", obj->pAddress);

  3. }

  4.  
Copyright GeekInterview.com

a. Your Name, Your Address

b. Your Address, Your Address

c. Your Name Your Name

d. None of the above

Questions by hardeep85

Showing Answers 1 - 2 of 2 Answers

wizard

  • Feb 27th, 2007
 

In first case the mem is allocated for struct but not for pName. so you will get runtime error as "Segmentation fault".

In second case also you will get the same, because here allocating memory and then freeing the object and then using in the printf statement. So obj is freed and your refering an unallocated memory. so you will get the same error.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions