Find the output of the following program:
void main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d", s->x);
printf("%s", s->name);
}
void main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d", s->x);
printf("%s", s->name);
}A. 3 and hello
B. 3 and h
C. 3 and garbage value
D. Compilation error
E. Runtime error
Answer: Option D
Solution (By Examveda Team)
You cannot initialize members in structure declaration.
Related Questions on Structure and Union
Which of the following can be a member of a structure?
A. Function
B. Another structure
C. Enumeration
D. All of the above

Join The Discussion