C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - True / False Questions (Q.No. 4)
4.
one of elements of a structure can be a pointer to the same structure.
Discussion:
6 comments Page 1 of 1.
TANIA CHAKRABORTY said:
1 year ago
A structure can be used like this. We call it as self-referential structure.
For example:
struct emp
{
int ecode;
struct emp *e;
};
For example:
struct emp
{
int ecode;
struct emp *e;
};
Shoaib said:
6 years ago
Is called as anonymous structure.
Venkat said:
8 years ago
Struct Indian
{
Int a;
Char C;
Struct Indian d;
}Ind;
In above program. The Compiler when checks d as a member but Indian data type not created yet.so complier no idea abt how much will allocate for this (d).So it throughs error.. if struct Indian *d here compiler know pointer having 4 bytes (in GCC) so *d is valid.
{
Int a;
Char C;
Struct Indian d;
}Ind;
In above program. The Compiler when checks d as a member but Indian data type not created yet.so complier no idea abt how much will allocate for this (d).So it throughs error.. if struct Indian *d here compiler know pointer having 4 bytes (in GCC) so *d is valid.
Sadiq said:
1 decade ago
Please give me example for this bit.
Ketan said:
1 decade ago
Yes, while creating linked list self referential structure is used.
For eg.
struct node
{
int data;
struct node *next; //self referential structures
}
For eg.
struct node
{
int data;
struct node *next; //self referential structures
}
Megha said:
1 decade ago
The concept used is self referential stuctures.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers