C - Structures,Unions - Discussion

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

 



Q.

#include

main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}

A. x B. y
C. s D. Compiler Error

Answer: Option D
Explaination:

The structure yy is nested within structure xx. Hence, the elements are of yy are to be accessed through the instance of structure xx, which needs an instance of yy to be known. If the instance is created after defining the structure the compiler will not know about the instance relative to xx. Hence for nested structure yy you have to declare member.



Discussion

Your Comments Goes here...
NameDiscussion