| | |
Deleting In Linked List..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
hi guyz.i've been working for this assignment in linked list for almost a week now..im complete making the program but i still have problem in deleting elements..in my program when i enter 1,2,3,4 and i want to delete 2..it deletes the 4 not the 2
..how will i solve this?..pls help..
..how will i solve this?..pls help.. C++ Syntax (Toggle Plain Text)
#include<iostream.h int main() { int i=1,d,n,list[100]; char ans,z,temp; do { cout<<"MENU OPTION\n"; cout<<"A.] Add\n"; cout<<"B.] Delete\n"; cout<<"C.] View list\n"; cout<<"Enter your Option: "; cin>>z; if(z=='a'||z=='A') { if(i>100) cout<<"Error: List FULL!!\n"; else { cout<<"Enter value to list: "; cin>>list[i]; i++; } } else if(z=='b'||z=='B') { if(i==1) cout<<"Error: No value to delete\n"; else { cout<<"Enter value to delete from list:"; cin>>temp; i--; for(d=1;d<i;d++) { if(temp==list[d]) list[d]=list[n]; n++; } } } else if(z=='c'|z=='C') { if(i==1) cout<<"Error: Empty list!!\n"; else { cout<<"list of values:\n"; for(d=1;d<i;d++) cout<<"list[d]<<Endl; } } else cout<<"Out of Range...\nInvalid Choice!!\n"; cout<<"Another Try?[y/n]"; cin>>ans; }while(ans=='y'||ans=='Y') return 0; }
I've got some bad news for you. Your existing code isn't using linked lists at all. It is using an array!
Before you can delete from a linked list you need to actually create a linked list.
Here is an introduction to linked lists.
Before you can delete from a linked list you need to actually create a linked list.
Here is an introduction to linked lists.
![]() |
Similar Threads
- Deleting Pointed node in Singly Linked List (C)
- Removing an item from head of linked list (C)
- Double-linked list in contiguous memory. (C)
- adding and deleting node in a linked list (C++)
- linked list..quick question (Java)
- Bumping my object on a linked list (C++)
Other Threads in the C++ Forum
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





