top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: In what cases, forward declaration of structure is preferred ?

+2 votes
409 views

I know about the forward declaration of structure but don't know when it should be used or preferrable ? I can't envision the scenario.

posted Sep 4, 2016 by Ganesh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

if Structure Defination is some where else but you want to use the structure as a data member of other structure defination in this case Structure forward declaration is required.

Ex:
typedef struct abc NODE;

struct xyz
{
NODE *link; /*Here if forword declaration is not present then compiler will pop up the error */
};

typedef struct abc
{
int a;
int b;
}NODE; //Here NODE will represent as a struct abc

answer Sep 8, 2016 by Vinay
...