this is my project and i need to submit it .

my program does not printing the records of the inputs
here's the code.hope someone will help

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

struct plane
{
char name[50];
int age;
char clas;
char des;
int sea;
char det;
char depd;
int counter;
struct plane *next;
};
struct plane* input();
void print(struct plane *pur);
struct plane* purchase_ticket(struct plane *pur);
struct plane* Seating_arr(struct plane *pur);
void search(struct plane *pur);

main()
{
printf("\n\t\t\t--WELCOME TO TRAVEL AND TOURS--\n");
printf("\n\n\t\t\t\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
{
struct plane *men;
int ch;
men=NULL;
while(ch)
{
printf("\n\t\t\tPress ''P'' to Purchase Ticket");
printf("\n\t\t\tPress ''S'' to View Seating Arrangement");
printf("\n\t\t\tPress ''A'' to Print Records");
printf("\n\t\t\tPress ''Q'' to Quit the system");
printf("\n\t\t\tPlease enter your response:");
scanf("%s",&ch);
switch(ch)
{
{

case 'P':
case 'p':
men=purchase_ticket(men);break;

case 'S':
case 's':
men=Seating_arr(men);break;

case 'A':
case 'a':
print(men);break;

case 'Q':
case 'q':
printf("Thank You for Visiting Us!");break;

default:
printf("INVALID RESPONSE!");

}
}
}
getch();
return 0;
}
}
struct plane* input()
{
struct plane *data;
printf("Name: ");
scanf("%s",data->name);
printf("Age: ");
scanf("%d",&data->age);
printf("Class: ");
scanf("%s",&data->clas);
printf("Destination: ");
scanf("%s",&data->des);
printf("SeatNo.: ");
scanf("%s",&data->sea);
printf("Departure Time: ");
scanf("%s",&data->det);
printf("Departure Date: ");
scanf("%s",&data->depd);
return data;
}

struct plane* purchase_ticket(struct plane *pur)
{
struct plane *temp;
temp = (struct plane*)malloc(sizeof(struct plane));
printf("\n Purchase Ticket\n");
printf("Name: ");
scanf("%s",temp->name);
printf("Age: ");
scanf("%d",&temp->age);
printf("Class: ");
scanf("%s",&temp->clas);
printf("Destination: ");
scanf("%s",&temp->des);
printf("SeatNo.: ");
scanf("%s",&temp->sea);
printf("\nPlease choose flight time\n\n");
printf(">> 7 a.m.\n\n");
printf(">> 10 am\n\n");
printf(">> 12 nn.\n\n");
printf(">> 7 pm\n\n");
printf(">> 10 p.m.\n\n");
printf("Departure Time.: ");
scanf("%s",&temp->det);
printf("Departure Date: ");
scanf("%s",&temp->depd);
temp->next = pur;
return temp;
}

struct plane* Seating_arr(struct plane *pur)
{
struct plane *temp;
struct plane *begin;
temp = (struct plane*)malloc(sizeof(struct plane));
{
int row,col;
int seats[5][5]={0};
printf("\t\tSeating In All Flights\n\n");
printf("\t1\t2\t3\t4\t5\n");
for (row=0; row<5; row++)
{
printf("\n%d", row+1);
for (col=0; col<5; col++)
{
printf("\t%d", seats[row][col]);
}
}


printf("\n\nNote: Please choose your seat using row and column format.\n\nFor example:To book seat at row 1 column 3 type 13\n\n");
printf("\n<< Legend >>\n\n");
printf("\n\nFirst Class Seats: 11,12,13,14,15\n\n");
printf("\n\nEconomy Class Seats: Other than the above\n\n");
}
}
void print(struct plane *pur)
{
printf("List of Passengers \n");
for(int i=1;pur=NULL;i++)
{
pur->counter=i;
printf("Name: %s\t Age: %d\tClass: %s\t Destination: %s\t SeatNo.: %d\t Departure Time: %s\t Departure Date: %s\n",pur->name,pur->age,pur->clas,pur->des,pur->sea,pur->det,pur->depd);
pur=pur->next;
}
printf("\n");
}
You need to initialize int ch;
You have some crazy memory things going on, you malloc data but never delete that memory. I don't understand what you're trying to do with your struct declarations, you probably intend to use a simple pointer to plane. I'm not sure if you intend to have your seating arrangement function actually show data, but you are showing an array that you initialize to 0. Most of this is C code, not C++, which would make your life much easier. I suggest you look into the basic class tutorials found on this site.
Topic archived. No new replies allowed.