Need examples of menu choices contected to linked lists

Reply

Join Date: Dec 2008
Posts: 40
Reputation: RenFromPenn is an unknown quantity at this point 
Solved Threads: 0
RenFromPenn RenFromPenn is offline Offline
Light Poster

Need examples of menu choices contected to linked lists

 
0
  #1
Jan 4th, 2009
Hi,

I need to create a menu of items that the user can select from. These choices will either create a linked list, add an item to the linked list, modify a current entry in the list, delete an entry, display the list, or exit the program.

I have looked every where for some examples to help me with this and I have found nothing. I googled. I searched c tutorials. I looked every where that I could think of with no luck. Does anyone know of a few good examples that I could look at to try and piece this thing together?

Thanks!

Ren
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,851
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Need examples of menu choices contected to linked lists

 
0
  #2
Jan 4th, 2009
And your point being what?
That sometimes no matter how much you google, that you can't find a ready-rolled answer?

What ever happened to trying your own homework.

I imagine the point is to see who's learnt something, not who's got the best google skills.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 40
Reputation: RenFromPenn is an unknown quantity at this point 
Solved Threads: 0
RenFromPenn RenFromPenn is offline Offline
Light Poster

Re: Need examples of menu choices contected to linked lists

 
0
  #3
Jan 4th, 2009
Originally Posted by Salem View Post
And your point being what?
That sometimes no matter how much you google, that you can't find a ready-rolled answer?

What ever happened to trying your own homework.

I imagine the point is to see who's learnt something, not who's got the best google skills.
No, my point wasn't that I wanted the answer. My point was that I wanted examples and tutorials because I can't find anything helpful and the book isn't helping me to figure this out.

I never said that I wanted the answer handed to me. I just wanted some help.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,004
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 172
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Need examples of menu choices contected to linked lists

 
0
  #4
Jan 4th, 2009
Have you first tried to learn how linked lists work?
Here.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 40
Reputation: RenFromPenn is an unknown quantity at this point 
Solved Threads: 0
RenFromPenn RenFromPenn is offline Offline
Light Poster

Re: Need examples of menu choices contected to linked lists

 
0
  #5
Jan 4th, 2009
Originally Posted by Aia View Post
Have you first tried to learn how linked lists work?
Here.
Yeah, I've read the book and I've read explanations online. The book has some sample programs for you to mess about with, but nothing like the the one that I described. I just really need a good tutorial to help me get my head around this. Surely there has to be a site that talks about linked lists, user selections, and that offers exercises so that I could get some practice.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,851
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Need examples of menu choices contected to linked lists

 
0
  #6
Jan 4th, 2009
Oh come on, any half-assed attempt at a linked list tutorial should tell you how to insert and delete an element.

As for the rest of the "problem", that's just generic menu selection consisting of
- print a number of choices (printf)
- input a choice (scanf)
- do the thing associated with the choice (if/else or a switch/case)

Now, what exactly is it that you're stuck on?

> I just wanted some help.
And how exactly are we supposed to know what you need help with, unless you post some kind of effort?

Because unless you do, then anything we do for you is precisely spoon-feeding, and something which you're claiming you don't want.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 25
Reputation: nitu_thakkar has a little shameless behaviour in the past 
Solved Threads: 1
nitu_thakkar's Avatar
nitu_thakkar nitu_thakkar is offline Offline
Light Poster

Re: Need examples of menu choices contected to linked lists

 
-1
  #7
Jan 5th, 2009
this example will help you to understand your query
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<alloc.h>
  4. #include<stdlib.h>
  5.  
  6. struct element
  7. {
  8. int info;
  9. struct element *next;
  10. }*start,*temp;
  11.  
  12. typedef struct element node;
  13.  
  14. void create();
  15. void insert();
  16. void dele();
  17. void display();
  18.  
  19. void main()
  20. {
  21. int ch;
  22. clrscr();
  23.  
  24. while(ch!=5)
  25. {
  26. printf("\nEnter Your Choice");
  27. printf("\n1.Create\n2.Insert\n3.Delete\n4.Display\n5.Exit");
  28. scanf("%d",&ch);
  29.  
  30.  
  31. switch(ch)
  32. {
  33. case 1:
  34. create();
  35. break;
  36. case 2:
  37. insert();
  38. break;
  39. case 3:
  40. dele();
  41. break;
  42. case 4:
  43. display();
  44. break;
  45. case 5:
  46. exit(0);
  47.  
  48. }
  49.  
  50. }
  51.  
  52.  
  53. }
  54.  
  55. void create()
  56. {
  57. int ch1;
  58. node *list,*newnode;
  59. clrscr();
  60.  
  61. printf("Enter The Element(For Exit Press -1):= ");
  62. scanf("%d",&ch1);
  63.  
  64. while(ch1!=-1)
  65. {
  66.  
  67. newnode=(node *)malloc(sizeof(node));
  68.  
  69. if(start==NULL)
  70. {
  71. start=newnode;
  72. }
  73.  
  74. newnode->info=ch1;
  75. newnode->next=NULL;
  76.  
  77. list->next=newnode;
  78. list=newnode;
  79.  
  80. printf("\nEnter The Element(For Exit Press -1):= ");
  81. scanf("%d",&ch1);
  82.  
  83. }
  84.  
  85.  
  86. }
  87.  
  88. void insert()
  89. {
  90. char ch;
  91. int newinfo,posi,i=2;
  92. node *prev,*newnode;
  93.  
  94. printf("\nEnter The Element:= ");
  95. scanf("%d",&newinfo);
  96.  
  97. do
  98. {
  99. printf("\nEnter The Position:= ");
  100. scanf("%d",&posi);
  101.  
  102. if(posi<1)
  103. {
  104.  
  105. printf("\nInvalid Position");
  106.  
  107. }
  108.  
  109. }while(posi<1);
  110.  
  111. newnode=(node *)malloc(sizeof(node));
  112. newnode->info=newinfo;
  113.  
  114. if((posi==1) || (start==NULL))
  115. {
  116. newnode->next=start;
  117. start=newnode;
  118. }
  119. else
  120. {
  121. prev=start;
  122.  
  123. while(i < posi )
  124. {
  125.  
  126. prev=prev->next;
  127. i++;
  128.  
  129. }
  130.  
  131. newnode->next=prev->next;
  132. prev->next=newnode;
  133. }
  134.  
  135. }
  136.  
  137. void dele()
  138. {
  139. int deleinfo;
  140. node *prev,*list;
  141.  
  142. printf("Enter The Element:= ");
  143. scanf("%d",&deleinfo);
  144.  
  145. if(start==NULL)
  146. {
  147. printf("List is Empty");
  148. getch();
  149. }
  150. else
  151. {
  152. prev=NULL;
  153. list=start;
  154.  
  155. while((list->info!=deleinfo) && (list->next!=NULL))
  156. {
  157.  
  158. prev=list;
  159. list=list->next;
  160.  
  161. }
  162.  
  163. }
  164.  
  165. if(list->info!=deleinfo)
  166. {
  167. printf("Element Not Found");
  168. }
  169.  
  170. else
  171. {
  172. if(prev==NULL)
  173. {
  174. //temp=temp->next;
  175. start=start->next;
  176. }
  177.  
  178. else
  179. {
  180. prev->next=list->next;
  181. }
  182. }
  183.  
  184.  
  185. }
  186.  
  187. void display()
  188. {
  189. temp=start;
  190. while(temp->next!=NULL)
  191. {
  192. printf("%d->",temp->info);
  193.  
  194. temp=temp->next;
  195. }
  196.  
  197. printf("%d",temp->info);
  198.  
  199.  
  200. }
Last edited by Ancient Dragon; Jan 5th, 2009 at 9:42 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,004
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 172
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Need examples of menu choices contected to linked lists

 
0
  #8
Jan 5th, 2009
>this example will help you to understand your query
What makes you think, that broken code is going to be of any help to anyone?

Obviously, you have chosen to not read about the expected conduct for this forum. Please, do, here and here, with an example here.

If you still, choose to ignore them, abstain of posting; it will be the best help you can give.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC