Hello to the community, i've just registered and i'm hoping if anyone can help me on this.
Well i'm not sure how i should explain my problem.
first off i'll start by posting my code.
Code:
it's an airline seats management system.
void FirstMenu() //can also be named "name menu"
{ blah codes here.
}
void PurchaseCustomTicket(int seatUserWants)
{
int x= seatUserWants-1;
if(seatings[plane][x]==1){ //if seat has been taken
printf("\nSeat has already been purchased.Please view the Seating display to identify a seat that you wish to buy.");
goto gotomenu; // i wish to go to the first line of my main function...
}
else
{blah codings}
}
void AutoPurchaseEconomyTicket()
{ blah codings}
void airlinesMenu()
{
blah codings......
if(plane<=0||plane>=11) //entering a valid plane value
{
printf("Invalid number, please enter the number associated to the flight you wish");
airlinesMenu(); //wishes to skip to the 2nd line of my main function.
}
else
{blah codings....}}}
void menu(){}
void submenu(){zzz}
int GetBSeatNumber(){}
int GetESeatNumber(){}
void DIS(int chairnum) // it's short for display info on seatings
{}
void DisplaySeating()
{printf("\n\n"); // just add some lines before displaying main menu again.
goto gotomenu; //wishes to go to the 1st line of main coding...
}
void CheckSeats()
{
if all seats have been taken
printf("All seats have been purchased for this flight.\nRedirecting you to first menu and please select another flight time.");
goto airlinesmenu; // going to the 2nd line main fuction
}
printf("Invalid Input, returning to main menu.\n"); //if there's an invalid input...
goto gotomenu; // go to the 2nd line of the main fuction
}
void DisplayBoardingTicket()
{system"cls");}
///////////////////////////////////////////////////////////////////////////////////////
void main()
{
firstmenu:
FirstMenu();
airlinesmenu:
airlinesMenu();
gotomenu:
menu();
if (choice=='P')
{
CheckSeats();
submenu();
if (choice=='B')
{
PurchaseCustomTicket(GetBSeatNumber());
DisplayBoardingTicket();
goto firstmenu;
}
if (choice=='E')
{
printf("\nDo you wish to manually buy a ticket(M) or auto purchase a ticket(A)?");
printf("\nEnter selection (M/A): ");
getchar();
scanf_s("%c", &choice);
if (choice=='M')
{
PurchaseCustomTicket(GetESeatNumber());
}
if(choice=='A')
{
AutoPurchaseEconomyTicket();
}
if(choice!='M'||choice!='A')
{
printf("Invalid Input, returning to main menu.\n");
goto gotomenu;
}
}
if(choice=='M')
printf("Main menu");
goto gotomenu;
}//end option P of main menu.
if(choice=='V')
{DisplaySeating();}
if(choice=='Q')
{printf("Exiting.");
getchar();
system ("cls");
goto firstmenu;
}
}
i didn't edit main. Anyway the problem is the labels firstmenu, airlinesmenu and gotomenu is inaccessible to the functions that's above main.... and i can't place those fuctions below main or else main won't be able to accesses those functions...
and if there's a way you can skip all codings and go to a specific line of of a specific function please tell me about it.
thanks in advance.