hello everyone. well here is my program. when i compile and build there are no errors. but when i reach the line enter your name, i enter the name and when i press carriage return, the whole program displays until the end without asking me any of the questions i have placed in printf..
Code:
# include <stdio.h>
# include <string.h>
#define NULL 0
void main()
{
void seat();
void new_ticket();
void list();
void exit();
int choice;
printf("\n ````````````` SaHaRa Travles PVT. LTD ```````````\n");
printf("\n -------------------------------------------------");
printf ("\n 1. Availability of seats \n");
printf("\n 2. New ticket issue \n");
printf("\n 3. Passenger list for each flight \n");
printf("\n 4. Exit \n");
printf("\n --------------------------------------------------");
printf("\n Enter your choice:");
choice = getchar();
switch (choice)
{
case '1':
seat();
break;
case '2':
new_ticket();
break;
case '3':
list();
break;
case '4':
exit();
break;
default :
main();
}
}
void seat()
{
printf("\n seat function incomplete.....");
}
void new_ticket()
{
FILE *fpt;
char name,choice,seat,*dest;
int s,p_cost;
dest="Honolulu";
fpt = fopen("Reservation.txt", "a+");
if (fpt==NULL)
printf("\n Error accessing file....");
else
printf("\n ------------------------- \n Proceeding to file creation and appending... \n");
for (s=0;s<51;++s)
{
printf("\n Destination:%s \n",dest);
printf("\n Enter your Name:");
scanf("%s",&name);
printf("\n Please select the type of seat you wish to book for: [Enter 'T' for tourist and 'F' for first class \n");
scanf("%c",&seat);
if (seat=='T')
p_cost=250;
else
p_cost=500;
printf("\n %d USD has been charged as your flight cost \n",p_cost);
printf("\n Your flight details has been logged in..... \n ");
fprintf(fpt,"%s %s %c %d",name,dest,seat,p_cost);
printf("\n Do you want to issue another ticket? Y or N");
scanf("%c",&choice);
if (choice=='Y')
continue;
else
break;
}
return 0;
}
a preview of what is displayed:
http://img85.imageshack.us/my.php?image=errorqt5.jpg