Guest User

Untitled

a guest
May 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.21 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.     int flight_code;
  8.     char flight_days [7+1];
  9.     char from_airport [3+1];
  10.     char to_airport [3+1];
  11.     short departure_time;
  12.     short arrival_time;
  13.     char airline_code [2+1];
  14.     short flight_number;
  15.     char class_string [10+1];
  16.     char aircraft_code [3+1];
  17.     char meal_code;
  18.     short stops;
  19.     char dual_carrier;
  20.     short time_elapsed;
  21.  
  22.     FILE *fp=NULL;
  23.  
  24.     fp=fopen("flight.csv","w");
  25.     if (fp==NULL)
  26.         {
  27.             printf("NEMOGU OTVORITI DATOTEKU");
  28.             exit(-1);
  29.         }
  30.  
  31.     printf("----------   DOBRODOSLI U AERODROM  ----------");
  32.     printf("\n----------ZAPISI O PUTNICKIM LETOVIMA----------");
  33.         do{
  34.  
  35.         printf("\n Flight Code: ");
  36.         scanf("%d", &flight_code);
  37.         if(flight_code==0) exit(-2);
  38.         printf("\n Flight days: ");
  39.         scanf("%s", &flight_days);
  40.  
  41.         printf("\n From airport: ");
  42.         scanf("%s", &from_airport);
  43.  
  44.         printf("\n To airport: ");
  45.         scanf("%s", &to_airport);
  46.  
  47.         printf("\n Departure time: ");
  48.         scanf("%hd", &departure_time);
  49.         printf("\n Arrival time: ");
  50.         scanf("%hd", &arrival_time);
  51.         printf("\n Airline code: ");
  52.         scanf("%s", &airline_code);
  53.  
  54.         printf("\n Flight number: ");
  55.         scanf("%hd", &flight_number);
  56.         printf("\n Class string: ");
  57.         scanf("%s", &class_string);
  58.  
  59.         printf("\n Aircraft code: ");
  60.         scanf("%s", &aircraft_code);
  61.  
  62.         printf("\n Meal code: ");
  63.  
  64.         scanf(" %c", &meal_code);
  65.         printf("\n Stops: ");
  66.         scanf("%hd", &stops);
  67.  
  68.         do{
  69.         printf("\n Dual carrier(Y/N): ");
  70.         scanf(" %c", &dual_carrier);
  71.         }while(dual_carrier!='Y'&&dual_carrier!='N');
  72.  
  73.         printf("\n Time elapsed: ");
  74.         scanf("%hd", &time_elapsed);
  75.  
  76.         fprintf(fp,"%d;%s;%s;%s;%hd;%hd;%s;%hd;%s;%s;%c;%hd;%c;%hd\n", flight_code,flight_days,from_airport,to_airport,departure_time,arrival_time,airline_code,flight_number,class_string,aircraft_code,meal_code,stops,dual_carrier,time_elapsed);
  77.         }while(flight_code);
  78.  
  79.     fclose(fp);
  80.  
  81.  
  82.     system("PAUSE");
  83.     return 0;
  84. }
Add Comment
Please, Sign In to add comment