C - Structures,Unions - Discussion

You Are Here :: Home > C > Structures,Unions - Discussion

 



Q.

#include

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 B. Hello
C. 3 Hello D. Compiler Error

Answer: Option D
Explaination:

Initialization should not be done for structure members inside the structure declaration



Discussion

Your Comments Goes here...
NameDiscussion