Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 163

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 61

Answer:

Is the following code legal?

struct a
{
int x;
struct a *b;
}


Answer:
Yes.


Explanation:
*b is a pointer to type struct a and so is legal. The compiler knows, the size of the pointer to a structure even before the size of the structure
is determined(as you know the pointer to any type is of same size). This type of structures is known as ‘self-referencing’ structure.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 163 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: