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:Download Da Code In C File .!!
:sad: :sad: :sad: :sad:
----------

/* 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;
	}
}

could you put code tag's around your code and then indent it!! Its hard to see whats what otherwise

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.

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.:(

UP


UP


:sad: :sad: :sad: :sad: :sad:

Bumping is considered bad form. I, and anyone who agrees, will now proceed to ignore you for the life of this thread.

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
:(

This article has been dead for over six months. Start a new discussion instead.