| | |
Can't Display These Topics By Sort?!!
![]() |
•
•
Join Date: Jan 2005
Posts: 7
Reputation:
Solved Threads: 0
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.s
ownload Da Code In C File .!!
----------
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.s
ownload Da Code In C File .!!
----------
C Syntax (Toggle Plain Text)
/* static queue */ #include<stdio.h> #include<string.h> # define max 5 int a; int i; int b; int araivno; struct data_type { int araivno; char name[20]; char msg[30]; }; void add (struct data_type); struct data_type remove1(void); void display(void); void disno(struct data_type); void adjustq(void); int rear = -1; int count = 0; struct data_type q[max]; main() { int option=0; struct data_type tempdata; clrscr(); do { printf("\n\n\n\n\t\t\t\t THE MENU"); printf("\n\t\t\t-----------------------------------"); printf("\n\n\t\t\t 1- Add\n"); printf("\t\t\t 2- Remove\n"); printf("\t\t\t 3- Display\n"); printf("\t\t\t 4- Display by number\n"); printf("\t\t\t 5- Quit\n"); printf("\n\t\t\t-----------------------------------"); printf("\n\t\t\t Enter your choice please:"); scanf(" %d",&option); switch(option) { case 1: clrscr(); if (count==max) { printf("\n\n\t\t\t Queue is FULL"); getch(); clrscr(); } else { clrscr(); printf("\n\n\n\t\t\t Araival Number:"); scanf("%d",&tempdata.araivno); printf("\n\t\t\t Name:"); scanf("%s",&tempdata.name); printf("\n\t\t\t Message:"); scanf("%s",&tempdata.msg); add (tempdata); clrscr(); } break; case 2: clrscr(); if (count==0) { printf("\n\n\t\t\t Queue is EMPTY"); getche(); } else { tempdata=remove1(); clrscr(); printf("\n\n\n\n\t\t The Removed Araival Number: %d",tempdata.araivno); printf("\n\n\t\t The Removed Name : %s",tempdata.name); printf("\n\n\t\t The Removed Message : %s", tempdata.msg); getche(); clrscr(); } break; case 3: clrscr(); display(); break; case 4: clrscr(); a=0; b=0; printf("\n\n\n\n\t\t Enter Arrival Nnumber: "); scanf("%d",&araivno); for(i=0;i<count;i++) { tempdata=i[q]; if (araivno==tempdata.araivno) { a=1; if(b==0) { printf("\t%s \t%s \t%s \n","Arrival No","Name","Message"); b=1; } printf("\t\t %d \t%s \t%s \n",tempdata.araivno,tempdata.name,tempdata.msg); } else { if(a==1) { a=1; } } } if(a==0) { printf("\n\n\t This number is not available \n\t Please try again ...\n"); getche(); clrscr(); } break; case 5: clrscr(); printf("\n\n\n\n\n\n\n\n\n\n\t\t\t\t End of the Program\n"); getche(); default: printf("\n\n\t\t\t Wrong Choice!!!! .... Try again"); break; } } while (option!=5); } void add (struct data_type data) { rear = rear + 1; count = count + 1; q[rear] = data; } struct data_type remove1(void) { struct data_type temp; temp = q[0]; adjustq(); return temp; } void display(void) { struct data_type data; int araivno; char name[20]; char msg[30]; int opt=0; int f=0; int i; do { clrscr(); for (i=f; i<f+4; i++) { data = q[i]; printf("\t%s \t%s \t%s \n","Arrival No","Name","Message"); printf("\t\t %d \t%s \t%s \n",data.araivno,data.name,data.msg); printf("\n\t\t================================\n"); } printf("\n\n Do you want to continue?? \n\n\t\t 1-Yes \n\t\t 2-No\n\n\t\t"); scanf("%d",&opt); f=f+2; clrscr(); } while (opt==1); } void adjustq(void) { int i; for (i=0; i<rear; i++) { q[i] = q[i+1]; rear = rear - 1; count = count -1; } }
Last edited by alc6379; Jan 31st, 2005 at 9:33 pm. Reason: added [code] tags
•
•
•
•
Originally Posted by Acidburn
could you put code tag's around your code and then indent it!! Its hard to see whats what otherwise
Alex Cavnar, aka alc6379
![]() |
Similar Threads
- PHP sort control (PHP)
- sort (C++)
- array struct display?? (C)
Other Threads in the C Forum
- Previous Thread: can someone please explain???????
- Next Thread: Print_Zero Function
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi







