Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- int flight_code;
- char flight_days [7+1];
- char from_airport [3+1];
- char to_airport [3+1];
- short departure_time;
- short arrival_time;
- char airline_code [2+1];
- short flight_number;
- char class_string [10+1];
- char aircraft_code [3+1];
- char meal_code;
- short stops;
- char dual_carrier;
- short time_elapsed;
- FILE *fp=NULL;
- fp=fopen("flight.csv","w");
- if (fp==NULL)
- {
- printf("NEMOGU OTVORITI DATOTEKU");
- exit(-1);
- }
- printf("---------- DOBRODOSLI U AERODROM ----------");
- printf("\n----------ZAPISI O PUTNICKIM LETOVIMA----------");
- do{
- printf("\n Flight Code: ");
- scanf("%d", &flight_code);
- if(flight_code==0) exit(-2);
- printf("\n Flight days: ");
- scanf("%s", &flight_days);
- printf("\n From airport: ");
- scanf("%s", &from_airport);
- printf("\n To airport: ");
- scanf("%s", &to_airport);
- printf("\n Departure time: ");
- scanf("%hd", &departure_time);
- printf("\n Arrival time: ");
- scanf("%hd", &arrival_time);
- printf("\n Airline code: ");
- scanf("%s", &airline_code);
- printf("\n Flight number: ");
- scanf("%hd", &flight_number);
- printf("\n Class string: ");
- scanf("%s", &class_string);
- printf("\n Aircraft code: ");
- scanf("%s", &aircraft_code);
- printf("\n Meal code: ");
- scanf(" %c", &meal_code);
- printf("\n Stops: ");
- scanf("%hd", &stops);
- do{
- printf("\n Dual carrier(Y/N): ");
- scanf(" %c", &dual_carrier);
- }while(dual_carrier!='Y'&&dual_carrier!='N');
- printf("\n Time elapsed: ");
- scanf("%hd", &time_elapsed);
- 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);
- }while(flight_code);
- fclose(fp);
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment