// (in) filename: name of file to write // (in) max_passenger: passenger with max items (as per assignment) // (in) max_flight: flight with max weight (as per assignment) void printResults(const char* filename, Passenger* max_passenger, Flight* max_flight) { FILE* output_file = fopen(filename, "w"); fprintf(output_file, "Passenger with max items: %s %s (%i items)\n", max_passenger->name.first_name, max_passenger->name.last_name, max_passenger->items_count); fprintf(output_file, "Flight with maximum weight: %s\n", max_flight->flight_no); printFlight(output_file, max_flight); fclose(output_file); }
void printAllFlights() { int i; for(i=0; i<number_of_flights; ++i) { printFlight(i); } }
void printFlightsWithDateToday() { time_t t = time(NULL); struct tm tm = *localtime(&t); char str[11]; sprintf(str,"%04d-%02d-%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); int anything_found=0; int i; for(i=0; i<number_of_flights; ++i) { if ( (strcmp(str, Tab[i].flight_start_date) ==0) //date matched with start date || (strcmp(str, Tab[i].flight_finish_date) ==0)) //date matched with end date { printFlight(i); anything_found=1; } } if (anything_found == 0) printf("No flights were found for date = %s\n\n", str); }
void printFlightsWithCity() { char city[255]; printf("Enter the city name: "); fflush(stdout); scanf("%s", city); printf("\n"); int anything_found=0; int i; for(i=0; i<number_of_flights; ++i) { if ( (strcmp(city, Tab[i].flight_from) ==0) //date matched with start date || (strcmp(city, Tab[i].flight_to) ==0)) //date matched with end date { printFlight(i); anything_found=1; } } if (anything_found == 0) printf("No flights were found for city = %s\n\n", city); }
void printFlightsWithDate() { char date[255]; printf("Enter the date you want to show flights on (format yyyy-mm-dd): "); fflush(stdout); scanf("%s", date); printf("\n"); int anything_found=0; int i; for(i=0; i<number_of_flights; ++i) { if ( (strcmp(date, Tab[i].flight_start_date) ==0) //date matched with start date || (strcmp(date, Tab[i].flight_finish_date) ==0)) //date matched with end date { printFlight(i); anything_found=1; } } if (anything_found == 0) printf("No flights were found for date = %s\n\n", date); }
void printFlightsWithId() { // pobieranie id char id[255]; printf("Enter the flight number: "); fflush(stdout); scanf("%s", id); printf("\n"); int anything_found=0; int i; for(i=0; i<number_of_flights; ++i) { if (strcmp(id, Tab[i].flight_id) ==0) //strings match { printFlight(i); anything_found=1; } } if (anything_found == 0) printf("No flights were found with id = %s\n\n",id); }