Professional Documents
Culture Documents
Self-Referential Structures - 1
Self-Referential Structures - 1
Self-Referential Structures - 1
#include <stdio.h>
struct student
{
char *c;
struct student *point;
};
void main()
{
struct student s;
struct student m;
s.c = m.c = "hi";
m.point = &s;
(m.point)->c = "hey";
printf("%s\t%s\t", s.c, m.c);
}
#include <stdio.h>
typedef struct p *q;
struct p
{
int x;
char y;
q ptr;
};
int main()
{
struct p p = {1, 2, &p};
printf("%d\n", p.ptr->x);
return 0;
}