answersLogoWhite

0

Self referential structures in c

Updated: 8/11/2023
User Avatar

Rethimanoj

Lvl 1
15y ago

Best Answer

a structure calling a same type of structure is refered to as self refrential ...like This is a very simple function that searches through a linked list using the struct above and returning true if the number is in the list, otherwise false. int list_search(int search, linklist *list) { int ans; if(list list->data) ans = 1; else ans = list_search(search, list->next); } return ans; } by cherry ..... cherrykapata@gmail.com

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

A structrure can contain a pointer to itself, or to other structures of the same type.

Example:

typedef struct TreeNode {

struct TreeNode *left, *right, *parent;

int value;

} TreeNode;

TreeNode tnexample = {NULL, NULL, &tnexample, 0};

Now tnexample is its own parent (do not do this is real life!).

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

typedef struct TreeNode {

struct TreeNode *left_child;

struct TreeNode *right_child;

struct TreeNode *parent;

} TreeNode;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Self referential structures in c
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is self referential function in c plus plus?

A self-referential function in C++, or in any other supporting language, is a recursive function.


What is referential class in c?

C is not an object-oriented language so it doesn't have classes of have any kind, it only has types. However, a self-referential type is simply a type that refers to itself. Nodes in a linked list are self-referential types because they hold a reference (a pointer) to the next node in the list: typedef struct node {node* next;/* ... */};


Do you ever have an answer?

As an example in self-referential paradox, the answer is NO!


What is self referential structure?

It is exactly what it sounds like: a structure which contains a reference to itself. A common occurrence of this is in a structure which describes a node for a linked list. Each node needs a reference to the next node in the chain. struct linked_list_node { int data; struct linked_list_node *next; // <- self reference };


What a structure must include if it is a self -referential structure in C programming?

Pointer, eg: struct Person { struct Person *father, *mother, *spouse; int age; char *name; };


What has the author Rashmi C Desai written?

Rashmi C. Desai has written: 'Dynamics of self-organized and self-assembled structures' -- subject(s): Phase rule and equilibrium, Dynamics, Pattern formation (Physical sciences)


What is a characteristic of Postmodern literature?

Postmodern literature often blurs the line between fiction and reality, challenges traditional narrative structures, and questions the concept of universal truths. It incorporates self-referential elements and metafictional techniques to explore themes of fragmentation, subjectivity, and the complexity of language.


How do stuctures in C and C plus plus differ?

Structures in C and C++ differ in that C structures do not have an automatic typdef associated with them.


What actors and actresses appeared in Self-erecting Structures - 2002?

The cast of Self-erecting Structures - 2002 includes: Jade Forster


What is autopoiesis?

Autopoiesis is a term coined by biologists Humberto Maturana and Francisco Varela to describe the self-organizing nature of living systems. It refers to the ability of an organism to continuously self-produce and self-maintain its organization through interactions with its environment. In essence, autopoietic systems are self-referential and self-sustaining.


C program for comparison of dates using structures?

C program for comparison of dates using structures


Write a program to implement domain and referential integrity?

give me the program which can related on domain and referential integrity.