A

Admin • 833K Points
Coach

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
  • Correct Answer - Option(B)
  • Views: 19
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

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.