Tuesday 23 April 2013

What is error in following declaration?


What is error in following declaration?

struct outer{
int a;
struct inner{
char c;
};
};


(A) Nesting of structure is not allowed in c.

(B)
It is necessary to initialize the member variable.

(C) Inner structure must have name.

(D) Outer structure must have name.

(E) There is not any error.


________________________________________
Explanation:
It is necessary to assign name of inner structure at the time of declaration other wise we cannot access the member of inner structure. So correct declaration is:
struct outer{
int a;
struct inner{
char c;
}name;
};

No comments:

Post a Comment