How to declare a structure of a linked list?
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Home
How to declare a structure of a linked list?
The right way of declaring a structure for a linked list in a C program is
struct node {
int value;
struct node *next;
};
typedef struct node *mynode;
Note that the following are not correct
typedef struct {
int value;
mynode next;
} *mynode;
The typedef is not defined at the point where the “next” field is declared.
struct node {
int value;
struct node next;
};
typedef struct node mynode;
You can only have pointer to structures, not the structure itself as its recursive!
Bookmark/Search this post with:
delicious delicious | digg digg | reddit reddit | magnoliacom magnoliacom | google google | yahoo yahoo | technorati technorati
» email this page
Post new comment
Subject:
Math Question: What is 6 + 8?: *
Please solve the math problem above and type in the result. e.g. for 1+1, type 2
Comment: *
Input format
Filtered HTML
* Allowed HTML tags:
BB Code
* Textual smileys will be replaced with graphical ones.
* You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options
Related Articles
- How do you find the middle of a linked list? Write a C program to return the middle of a linked list
- How do you reverse a singly linked list? How do you reverse a doubly linked list? Write a C program to do the same.
- What are Preprocessor Directives ?
- How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.
- How would you detect a loop in a linked list? Write a C program to detect a loop in a linked list.


