| | |
inserting a node befora certain node in doubly linklist
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Solved Threads: 0
iv written a code that insert a node befor a node containing a certain value(for example insert a node having value 3,befor the node containing value5),i checked the code many times,i couldnt find any mistake, but the compiler errors this part. can any one help.
here is the code :
here is the code :
C++ Syntax (Toggle Plain Text)
void insert_b4_search(int ai,int bj)// ai is the value we are looking for in the linklist . bi is the value od the new node { node *temp; temp = head; while(temp != NULL && temp-> num != ai)//num=value {temp = temp -> nxt; if(temp == NULL){ cout<<"ooo"<<endl; } } if (temp == head){ insert_at_first(bj);//call add at first method } else if(temp == tail){ insert_to_tail(bj); } else { ptr = new node(bj,NULL,NULL); ptr->prev = new node(bj, ptr->prev, ptr); ptr->prev->prev->next = ptr->prev; } }
it would be better if you can align your code first with respect to { and }
Is this one line or 2 line
C++ Syntax (Toggle Plain Text)
)// ai is the value we are looking for in the linklist . bi is the value od the new node
![]() |
Similar Threads
- Removing an item from head of linked list (C)
- adding and deleting node in a linked list (C++)
- two array comparison (C++)
- Doubly linked circular list (C)
- Stacks using doubly linked lists (C++)
- searching and inserting node in a binary search tree (C)
Other Threads in the C++ Forum
- Previous Thread: Structures and functions
- Next Thread: An equivalent method of substr() in C
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion convert count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






