Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void print_menu (void)
- {
- printf("\n");
- printf("1. add a flight\n");
- printf("2. display all flights to a destination\n");
- printf("3. save the flights to the database file\n");
- printf("4. load the flights from the database file\n");
- printf("5. exit the program\n");
- printf("Enter choice (number between 1-5)>\n");
- }
- flights_t add_flight(index)
- {
- /* Set up a verable for getting data */
- flights_t temp_flight;
- int j,i=0;
- /* in array for flights is full do not add more. */
- if(index >= MAX_NUM_FLIGHTS)
- {
- printf("Cannot add more flights - memory full\n");
- return temp_flight;
- }
- /* Scan in flight code one char at a time */
- printf("Enter flgiht code>\n");
- for(j=0; j<MAX_FLIGHTCODE_LEN-1; j++)
- {
- scanf("%c", &temp_flight.flightcode[j]);
- }
- temp_flight.flightcode[i] = '\0';
- fflush(stdin);
- printf("Flight code entered: %s\n", temp_flight.flightcode);
- printf("Enter depature info for the flight leaving sydney.\n");
- while (i ==0)
- {
- printf("Enter month, date , hour and minute separated by spaces>\n");
- /* scan in depature time in formate day month hour year */
- scanf("%d",&temp_flight.departure_dt.month);
- scanf("%d",&temp_flight.departure_dt.day);
- scanf("%d",&temp_flight.departure_dt.hour);
- scanf("%d",&temp_flight.departure_dt.minute);
- if(valid_input(3,temp_flight)==0)
- {
- printf("Valid date\n");
- i++;
- }
- else
- {
- printf("invalid date\n");
- }
- }
- fflush(stdin);
- i=0;
- /* Scan in arrival city code on char at a time */
- while(i==0)
- {
- printf("Enter arrival city code>\n");
- for(j=0;j<MAX_CITYCODE_LEN-1;j++)
- {
- scanf(" %c",&temp_flight.arrival_city[j]);
- temp_flight.arrival_city[j] = '\0';
- }
- printf("City code entered: %s\n", temp_flight.arrival_city);
- if(valid_input(4, temp_flight)==0)
- {
- printf("Valid input\n");
- i++;
- }
- else
- {
- printf("invalid input\n");
- }
- }
- i=0;
- /* Scan in arival date and time */
- fflush(stdin);
- printf("Enter arrival info.\n");
- while(i==0)
- {
- printf("Enter month, date, hour and minute separated by spaces>\n");
- scanf(" %d",&temp_flight.arrival_dt.month);
- scanf(" %d",&temp_flight.arrival_dt.day);
- scanf(" %d",&temp_flight.arrival_dt.hour);
- scanf(" %d",&temp_flight.arrival_dt.minute);
- if(valid_input(2,temp_flight)==0)
- {
- printf("Valid date\n");
- i++;
- }
- else
- {
- printf("invalid date\n");
- }
- }
- fflush(stdin);
- return temp_flight;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement