3 Replies - 1131 Views - Last Post: 07 March 2009 - 12:08 AM Rate Topic: -----

#1 philboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-March 09

HELP with Structure Problem in C!

Posted 06 March 2009 - 11:22 PM

Hi to all. Problem: Make an airline reservation program in C. The passenger capacity is 12.
Use the following menu:
-Menu-
[a]RESERVE
[b]DISPLAY
[c]PRINT
[d]QUIT

Here's what i've made so far.. (Sorry i'm a noob)
//Structure Problem

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

void reserve();
void display();
void print();

typedef struct data{
		char surname[20];
		char firstname[20];
		char age[3];
		char address[50];
		char gender[6];
		char date[30];
		char time[20];
		char destination[30];
		char point_of_origin[30];
		char accomodation[15];
		char contact_number[11];
		}INFO;
int main(void)
{
	int x;
	char choice;
	char *a,*b,*c,*d,*e,*f,*g,*h;
	for(x=0;x<12;x++)
	{
	a="* WELCOME TO BLAH AIRLINES *";
	b="*********** MENU ***********";
	c="* [a] RESERVE				*";		  
	d="* [b] DISPLAY					*";
	e="* [d] PRINT					*";
	f="* [q] QUIT					*";
	g="****************************";
	h=">>Enter your choice: ";
	printf("\n%s\n%s\n\n%s\n%s\n%s\n%s\n\n%s\n%s",a,b,c,d,e,f,g,h);
	choice=getche();
	switch(choice)
	{
	 case 'a':
		  if(x>0)
		  {
		  printf("\n\nSorry.. Fully Booked already!\n\n");
		  break;
		  }
		  else
		  reserve();
		  break;
	 case 'b':
		  display();
		  break;
	 case 'c':
		  print();
		  break;
	 case 'q':
		  exit(0);
	 default:
			 printf("\n\nWrong key!\n\n");
	 }
	 }
	 getch();
	 return 0;
}		 
void reserve()
{	
	 
	 INFO passenger[12];
	 int x;
	 for(x=0;x<12;x++)
	 {
	 fflush(stdin);
	 printf("\n\n***** RESERVATION FORM *****");				 
	 printf("\n\n//PASSENGER[%d]//\n",x);
	 printf("Surname		 : ");
	 gets(passenger[x].surname);
	 printf("Firstname	   : ");
	 gets(passenger[x].firstname);
	 printf("Age			 : ");
	 gets(passenger[x].age);
	 printf("Address		 : ");
	 gets(passenger[x].address);
	 printf("Gender		  : ");
	 gets(passenger[x].gender);
	 printf("Date			: ");
	 gets(passenger[x].date);
	 printf("Time			: ");
	 gets(passenger[x].time);
	 printf("Destination	 : ");
	 gets(passenger[x].destination);
	 printf("Point of origin : ");
	 gets(passenger[x].point_of_origin);
	 printf("Accomodation	: ");
	 gets(passenger[x].accomodation);
	 printf("Contact Number  : ");
	 gets(passenger[x].contact_number);
	 printf("\nReservation added.. Thank You!");
	 }
	 printf("Fully Booked!\n\n");
	 return;
}
void display()
{
	 int x;						   //IT DISPLAYS FUNNY CHARACTERS ..
	 
	 printf("\nEnter passenger#: ");
	 scanf("%d",&x);
	 INFO passenger[x];
	 
	 printf("\n\n//PASSENGER[%d]//\n",x);
	 printf("Surname		 : ");
	 puts(passenger[x].surname);
	 printf("Firstname	   : ");
	 puts(passenger[x].firstname);
	 printf("Age			 : ");
	 puts(passenger[x].age);
	 printf("Address		 : ");
	 puts(passenger[x].address);
	 printf("Gender		  : ");
	 puts(passenger[x].gender);
	 printf("Date			: ");
	 puts(passenger[x].date);
	 printf("Time			: ");
	 puts(passenger[x].time);
	 printf("Destination	 : ");
	 puts(passenger[x].destination);
	 printf("Point of origin : ");
	 puts(passenger[x].point_of_origin);
	 printf("Accomodation	: ");
	 puts(passenger[x].accomodation);
	 printf("Contact Number  : ");
	 puts(passenger[x].contact_number);
	 printf("\n\n");
	 return;
}
void print()
{
						   //I DON'T KNOW HOW TO PRINT THIS..
	 return;
}



Please help me.. Thanks Guys!

This post has been edited by philboy: 06 March 2009 - 11:24 PM


Is This A Good Question/Topic? 0
  • +

Replies To: HELP with Structure Problem in C!

#2 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 768
  • View blog
  • Posts: 3,832
  • Joined: 25-October 06

Re: HELP with Structure Problem in C!

Posted 06 March 2009 - 11:53 PM

what is your problem?

This post has been edited by horace: 07 March 2009 - 12:04 AM

Was This Post Helpful? 0
  • +
  • -

#3 cmaster  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 53
  • Joined: 18-November 08

Re: HELP with Structure Problem in C!

Posted 06 March 2009 - 11:54 PM

Do you mean printing to the printer device?
Was This Post Helpful? 0
  • +
  • -

#4 philboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-March 09

Re: HELP with Structure Problem in C!

Posted 07 March 2009 - 12:08 AM

View Postcmaster, on 6 Mar, 2009 - 10:54 PM, said:

Do you mean printing to the printer device?

yes.


The problem is when I display the info of every passenger, the output are funny characters. And, I also don't know how to print the passenger info to the printer. I'm using Dev-C++ by the way.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1