Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.79 KB | None | 0 0
  1. void addFlight(int flight_counter){
  2.     int fcl = 1, dl = 1, i;
  3.     while(fcl){
  4.         i = 0;
  5.         char temp[MAX_FLIGHTCODE_LENGTH];
  6.  
  7.  
  8.         printf("Enter flight code>\n");
  9.         scanf("  %[^\n]s", temp);
  10.         for(i = 0; i <= MAX_FLIGHTCODE_LENGTH; i++){
  11.             if(i < 2 && temp[i] >= 'A' && temp[i] <= 'Z'){
  12.                 flights[flight_counter].flightcode[i] = temp[i];
  13.             }
  14.             else if(i >= 2 && temp[i] >= '0' && temp[i] <= '9'){
  15.                 flights[flight_counter].flightcode[i] = temp[i];
  16.             }
  17.             else if((temp[i] == '\0' || temp[i] == '\n') && i != 2){
  18.                 fcl = 0;
  19.             }
  20.             else{
  21.                 printf("Invalid input\n");
  22.                 for(i = 0; i <= MAX_FLIGHTCODE_LENGTH; i++){
  23.                     temp[i] = '\0';
  24.                 }
  25.                 fcl = 1;
  26.             }
  27.         }
  28.     }
  29.     while(dl){
  30.         struct dt_temp{
  31.             int month;
  32.             int day;
  33.             int hour;
  34.             int minute;
  35.         };
  36.         typedef struct dt_temp dt_temp_t;
  37.         printf("Enter departure info for the flight leaving SYD.\n");
  38.         printf("Enter month, date, hour and minute separated by spaces>\n");
  39.         scanf(" %d", &flights[flight_counter].departure_dt.month);
  40.         scanf(" %d", &flights[flight_counter].departure_dt.day);
  41.         scanf(" %d", &flights[flight_counter].departure_dt.hour);
  42.         scanf(" %d", &flights[flight_counter].departure_dt.minute);
  43.         printf("%d %d %d %d\n", flights[flight_counter].departure_dt.month, flights[flight_counter].departure_dt.day, flights[flight_counter].departure_dt.hour, flights[flight_counter].departure_dt.minute);
  44.         if(dt_temp_t.month > 0 && dt_temp_t.month <= 12){
  45.            
  46.         }
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement