Singly Linked List

Can anyone help me?

I want to insert data before head.

example :
3 4 5
I want insert 2 before 3,,but I get an error in C++ program.

This is my script

void insert_before(int s)
Node *before=head;
if(before->next->Data!=s) { //Example. Data = 2 and s = 3 4 5
else {
I do not see where you create a new Node for the inserted data.
Show the definition of the Node.
Topic archived. No new replies allowed.