Get Started
728

Q: What would be the output of the following program? main() {    struct emp    {         char *n;         int age;    };    struct emp e1 = { "Dravid", 23};    struct emp e2 = e1;    strupr (e2.n);    printf ("\n%s",e1.n); }

  • Show Answer
  • Workspace

Answer :
Explanation :

DRAVID When a structure is assigned, passed, or returned, the copying is done monolithically. This means that the copies of any pointer fields will point to the same place as the original. In other words, anything pointed to is not copied. Hence, on changing the name through e2.n it automatically changed e1.n

The Most Comprehensive Exam Preparation Platform

Get the Examsbook Prep App Today