Puneet said:
Hi,
I have to know how to delete a node in link list.
i have a single link list like this
1->2->3->4->5->6->7
now i dont know head pointer. I know only the pointer which is pointing
to item 5 in above list. Now i want to delete the item 5 so how i will
do that ??
can anybody help me....
Since you must modify the pointer in node4 which points to node5, it is
impossible to do what you want knowing only the value of the pointer to
node5. You *must* know where one of node1, node2, node3, or node4 is.
For some reason we get lots of questions about linked lists in
comp.lang.c. For some strange reason, they are almost always answered.
Yet they are completely off-topic. There is *nothing* about the C
programming language involved here.
Despite the fact that your lecturer or your textbook has doubtless made
it clear how to do this and you were not paying attention, you could --
if you thought about it -- have come up with tne process.
You have
ptr to node4 -> node4
ptr to node5 -> node5
ptr to node6 -> node6
You want to change this to
ptr to node4 -> node4
ptr to node6 -> node6
Obviously you want to replace the value of the pointer in node4 with a
pointer to node6. Where do you get that value? Where do you put it?
What do you do with the memory allocated to node5? Isn't this really a
very baby problem for you not to have worked out for yourself?