| | |
inserting a node befora certain node in doubly linklist
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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
Views: 1274 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct temperature template templates text tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






