| | |
Deleting In Linked List..
![]() |
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
- 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++)
- Deleting Pointed node in Singly 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 auto based beginner binary bitmap c++ c/c++ calculator challenge char class classes code coding compile console conversion count delay-loading delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption equation error file forms fstream function functions game garbage givemetehcodez graph gui hmenu homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node output parameter performance pointer primenumbersinrange problem program programming project python random read recursion reference rpg sockets string strings temperature template test text text-file tivoli tree url variable vector video win32 windows winsock wordfrequency wxwidgets





