Can't Display These Topics By Sort?!!

Reply

Join Date: Jan 2005
Posts: 7
Reputation: {{unknown}} is an unknown quantity at this point 
Solved Threads: 0
{{unknown}} {{unknown}} is offline Offline
Newbie Poster

Can't Display These Topics By Sort?!!

 
0
  #1
Jan 31st, 2005
Hi…
Please I Need To Know How can I Display All The Topics Which I Added By Sorting In Option 3?
I Programmed The Option (Case3) 3 To Display All Da Topics but I Need To Put Them In Order. Please Can Anyone help me In Adding The Code In Case 3 So That It Sorts By Order?
Code Is Below
P.sownload Da Code In C File .!!

----------
  1. /* static queue */
  2. #include<stdio.h>
  3. #include<string.h>
  4. # define max 5
  5. int a;
  6. int i;
  7. int b;
  8. int araivno;
  9.  
  10. struct data_type
  11. {
  12. int araivno;
  13. char name[20];
  14. char msg[30];
  15. };
  16.  
  17. void add (struct data_type);
  18. struct data_type remove1(void);
  19. void display(void);
  20. void disno(struct data_type);
  21. void adjustq(void);
  22.  
  23. int rear = -1;
  24. int count = 0;
  25.  
  26. struct data_type q[max];
  27. main()
  28. {
  29. int option=0;
  30. struct data_type tempdata;
  31. clrscr();
  32. do
  33. {
  34.  
  35. printf("\n\n\n\n\t\t\t\t THE MENU");
  36. printf("\n\t\t\t-----------------------------------");
  37. printf("\n\n\t\t\t 1- Add\n");
  38. printf("\t\t\t 2- Remove\n");
  39. printf("\t\t\t 3- Display\n");
  40. printf("\t\t\t 4- Display by number\n");
  41. printf("\t\t\t 5- Quit\n");
  42. printf("\n\t\t\t-----------------------------------");
  43. printf("\n\t\t\t Enter your choice please:");
  44. scanf(" %d",&option);
  45. switch(option)
  46. {
  47. case 1:
  48. clrscr();
  49. if (count==max)
  50. {
  51. printf("\n\n\t\t\t Queue is FULL");
  52. getch();
  53. clrscr();
  54. }
  55.  
  56. else
  57.  
  58. {
  59. clrscr();
  60. printf("\n\n\n\t\t\t Araival Number:");
  61. scanf("%d",&tempdata.araivno);
  62. printf("\n\t\t\t Name:");
  63. scanf("%s",&tempdata.name);
  64. printf("\n\t\t\t Message:");
  65. scanf("%s",&tempdata.msg);
  66. add (tempdata);
  67. clrscr();
  68. }
  69. break;
  70.  
  71. case 2:
  72. clrscr();
  73. if (count==0)
  74. {
  75. printf("\n\n\t\t\t Queue is EMPTY");
  76. getche();
  77. }
  78.  
  79. else
  80.  
  81. {
  82. tempdata=remove1();
  83. clrscr();
  84. printf("\n\n\n\n\t\t The Removed Araival Number: %d",tempdata.araivno);
  85. printf("\n\n\t\t The Removed Name : %s",tempdata.name);
  86. printf("\n\n\t\t The Removed Message : %s", tempdata.msg);
  87. getche();
  88. clrscr();
  89. }
  90. break;
  91.  
  92. case 3:
  93. clrscr();
  94. display();
  95. break;
  96.  
  97. case 4:
  98. clrscr();
  99. a=0;
  100. b=0;
  101. printf("\n\n\n\n\t\t Enter Arrival Nnumber: ");
  102. scanf("%d",&araivno);
  103. for(i=0;i<count;i++)
  104. {
  105. tempdata=i[q];
  106. if (araivno==tempdata.araivno)
  107. {
  108. a=1;
  109. if(b==0)
  110. {
  111. printf("\t%s \t%s \t%s \n","Arrival No","Name","Message");
  112. b=1;
  113. }
  114. printf("\t\t %d \t%s \t%s \n",tempdata.araivno,tempdata.name,tempdata.msg);
  115. }
  116. else
  117. {
  118. if(a==1)
  119. {
  120. a=1;
  121. }
  122. }
  123. }
  124. if(a==0)
  125. {
  126. printf("\n\n\t This number is not available \n\t Please try again ...\n");
  127. getche();
  128. clrscr();
  129. }
  130. break;
  131.  
  132. case 5:
  133. clrscr();
  134. printf("\n\n\n\n\n\n\n\n\n\n\t\t\t\t End of the Program\n");
  135. getche();
  136.  
  137. default:
  138. printf("\n\n\t\t\t Wrong Choice!!!! .... Try again");
  139. break;
  140. }
  141. }
  142. while (option!=5);
  143. }
  144.  
  145. void add (struct data_type data)
  146. {
  147. rear = rear + 1;
  148. count = count + 1;
  149. q[rear] = data;
  150. }
  151.  
  152. struct data_type remove1(void)
  153. {
  154. struct data_type temp;
  155. temp = q[0];
  156. adjustq();
  157. return temp;
  158. }
  159.  
  160. void display(void)
  161. {
  162. struct data_type data;
  163. int araivno;
  164. char name[20];
  165. char msg[30];
  166. int opt=0;
  167. int f=0;
  168. int i;
  169. do
  170. {
  171. clrscr();
  172. for (i=f; i<f+4; i++)
  173. {
  174. data = q[i];
  175. printf("\t%s \t%s \t%s \n","Arrival No","Name","Message");
  176. printf("\t\t %d \t%s \t%s \n",data.araivno,data.name,data.msg);
  177. printf("\n\t\t================================\n");
  178. }
  179. printf("\n\n Do you want to continue?? \n\n\t\t 1-Yes \n\t\t 2-No\n\n\t\t");
  180. scanf("%d",&opt);
  181. f=f+2;
  182. clrscr();
  183. }
  184. while (opt==1);
  185. }
  186.  
  187. void adjustq(void)
  188. {
  189. int i;
  190. for (i=0; i<rear; i++)
  191. {
  192. q[i] = q[i+1];
  193. rear = rear - 1;
  194. count = count -1;
  195. }
  196. }
Last edited by alc6379; Jan 31st, 2005 at 9:33 pm. Reason: added [code] tags
Attached Files
File Type: c Booking.C (3.5 KB, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Re: Can't Display These Topics By Sort?!!

 
0
  #2
Jan 31st, 2005
could you put code tag's around your code and then indent it!! Its hard to see whats what otherwise
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Can't Display These Topics By Sort?!!

 
0
  #3
Jan 31st, 2005
Originally Posted by Acidburn
could you put code tag's around your code and then indent it!! Its hard to see whats what otherwise
I took care of that. Since that's out of the way, could the OP please make it a point to use correct English here? Slang isn't cute, and it gets in the way of helping you resolve your issue.
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 7
Reputation: {{unknown}} is an unknown quantity at this point 
Solved Threads: 0
{{unknown}} {{unknown}} is offline Offline
Newbie Poster

Re: Can't Display These Topics By Sort?!!

 
0
  #4
Feb 1st, 2005
Thanks for the quick reply and note taken about the slang
I'm still waiting for a solution for the problem can anyone help me? please.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 7
Reputation: {{unknown}} is an unknown quantity at this point 
Solved Threads: 0
{{unknown}} {{unknown}} is offline Offline
Newbie Poster

Re: Can't Display These Topics By Sort?!!

 
0
  #5
Feb 2nd, 2005
UP








UP




Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,614
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Can't Display These Topics By Sort?!!

 
0
  #6
Feb 2nd, 2005
Originally Posted by {{unknown}}
UP








UP




Bumping is considered bad form. I, and anyone who agrees, will now proceed to ignore you for the life of this thread.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 7
Reputation: {{unknown}} is an unknown quantity at this point 
Solved Threads: 0
{{unknown}} {{unknown}} is offline Offline
Newbie Poster

Re: Can't Display These Topics By Sort?!!

 
0
  #7
Feb 2nd, 2005
Sorry But Is there anyway I can get attention other than this? I apologize for this if disturbs anyone but i need the salution badly
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC