Linked list

I am still new to linked list, how to implement the linked list after i struct node{int items;node* next;};
Search the forum for "Linked list" and you'll find many threads that address this issue. A few common beginner problems come to mind:
1. Create separate classes for the Node in the list, and the list itself. The list class contains a private Node pointer (the head of the list) and the methods to insert/search/delete etc.
2. The Node class should contain a constructor. This will help reduce the code and avoid errors. For your example:
1
2
3
4
5
6
struct node {
    int items;
    node *next;
    node(int val) :
        items(val), next(nullptr) {}
};

You really need to learn how to use google, a lot of your questions on this forum can be answered by a simple google search, Linked lists has been done a million times, and all the information you need can be easily accessed. No need to create a new thread for such a generic question.
Last edited on
Dhayden i dont understand what u saying
Can you be more specific? What don't you understand?
i just now how to struct only after that i dont know anything about it
Is this part of an assignment? If not maybe you should learn the basics first, linked lists are not so easy.
i just know linked list need use pointers
You know, what you really need is:

(a) a massive repository of information, including tutorials on subjects like this
(b) some kind of free, publicly available tool for retrieving information from that repository.

If only any of us could think of something like that, that we could recommend you use!
Wouldnt life be much easier if we had such a thing @MikeyBoy? I only hope the future brings it so we can all have a better life, especially for our children.
Ah, you crazy dreamer, you!
i cant find any useful articles on web
I find that hard to believe. Writing a linked list is a very, very common tutorial exercise, and there must be - literally - thousands of examples online.

If you have a specific question about linked lists that you can't find an answer for, then you need to ask that specific question.
why they need constructor inside the structure?
For the same reason as you'd put a constructor inside any class or struct: to initialise the state of the object.
Linked list in c is not suitable for me
Topic archived. No new replies allowed.