---------- Post updated at 01:05 PM ---------- Previous update was at 01:03 PM ----------
HI,
I am trying to write a program for single linked list. But the problem is the in the while loop in the below written program the value of the nodes created is not getting saved.
Like for example if I try to display the list..all I get is 0 10
Pls help me understand this.
thnx in advance
Prince
Last edited by Corona688; 02-26-2013 at 05:47 PM..
You link the 1st element to the newly created element, which then links to NULL.
So you always have the 1st and the latest element - the intermediate elements are lost.
Thanks Germany,
You mean I should have done that last linking.
All what I want to do is to link the newly created element to NULL and link Start to the newly created element.
Please can you also tell me what could there be..instead of what I have written.
Thanks for the reply. It really helped. But I was wondering if I do that in the code, it would certainly add the new nodes at the beginning. What If I want to add them at the end?
Linking at the beginning is easier.
Linking at the end either requires traversing to the end of the list, then linking to it.
Or, more efficient, have an external end pointer in addition to the start pointer:
This time we need an if clause, because the first element needs to be treated differently.
Last edited by MadeInGermany; 02-27-2013 at 02:02 PM..
Reason: Forgot to update the end pointer
Hi, I am programming in kernel, and I want to use a double linked list that holds infos that every process could access and modify THIS list. So, I suppose it is a 'global' variable since every process(thread) can reach it, I am wondering where to put it? by changing some of the kernel files? (1 Reply)
can someone provide an example of a struct linked list, where it has strings as its values, and then how do I check if a specific string (say called buffer) exists in the list of structs?
i dont understand how to make a copy of it to check with
this is what i have
... (0 Replies)
i have a linked list set up like
typedef struct client_list {
char *client_name;
int client_socket_fd;
struct client_list *next;
} client;
client *client_list=NULL;
before adding to the list i check if it already exists, only if it does not then i add
if (client_list==NULL... (1 Reply)