R

Rajeev Malhotra • 3.97K Points
Extraordinary

Q. What will be the output of this code?

Code:
void main()
{
      struct xx
      {
            int x=3;
            char name[] = "hello";
      };
      struct xx *s = malloc(sizeof(struct xx));
      printf("%d", s->x);
      printf("%s", s->name); 
}
  • (A) 3 hello
  • (B) Compiler Error
  • (C) Linking error
  • (D) None of these

Explanation by: Rajeev Malhotra
Initialization should not be done for structure members inside the structure declaration.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics