Question
What is the problem with my C++ code till this point. How to fix them. (functions.cpp main.cpp header.hpp) functions.cpp #include header.hpp int loadFlights(flightInfo infos[listSize],flightInfo &info)
What is the problem with my C++ code till this point. How to fix them. (functions.cpp main.cpp header.hpp)
functions.cpp
#include "header.hpp"
int loadFlights(flightInfo infos[listSize],flightInfo &info) { int SIZE = 0; ifstream file; cout << "What is the name of the flight data file? "; cin.getline(fileName,SIZE); file.open(fileName); while (!file.is_open()) { cout << "File doesn't exist, please try again: "; cin.getline(fileName,SIZE); } while(true) { file.getline(info.airline,SIZE,','); file >> info.flightNum; cin.ignore(); file >> info.departMonth; cin.ignore(); file >> info.departDay; cin.ignore(); file >> info.departTime; cin.ignore(); file >> info.arriveMonth; cin.ignore(); file >> info.arriveDay; cin.ignore(); file >> info.arriveTime; cin.ignore(); file.getline(info.departAirport,SIZE,','); file.getline(info.arriveAirport,SIZE,','); } } void addFlight(flightInfo &info) { cout << "What is the name of the ariline? "; cin.getline(info.airline,SIZE); cout << "What is the flight number? "; cin >> info.flightNum; } template
void listFlights(flightInfo infos[],int count){ dataRow("Airline","Flight#","Departure"," "," ","Arroval"," "," ","From","To"); for (int i = 0; i ______________________________ main.cpp #include "header.hpp" int main() { flightInfo infos[listSize]; cout << "Welcome to the program." << endl; loadFlights(flightInfo infos[listSize],flightInfo &info); cout << "What would you like to do: (l)ist all, (s)earch, (a)dd an exercise, or (q)uit?: " << endl; cin.getline(choice,SIZE); if (choice == 'l') { listFlights(infos,SIZE); } else if (choice == 's') { searchFlights(infos,SIZE); } return 0; } __________________________________________________ header.hpp #ifndef __HEADER__ #define __HEADER__ #include using namespace std; const int SIZE = 128; const int listSize = 100; char fileName[SIZE]; int flightCount = 0; //Declaring Prototypes int loadFlights(flightInfo infos[listSize], flightInfo &info); void addFlight(flightInfo &info); void dataRow(A,B,C,D,E,F,G,H,I,J); bool searchFlights(flightInfo infos[], int count); void listFlights(flightInfo infos[], int count); struct flightInfo { char airline[SIZE]; int flightNum; int departMonth; int departDay; double departTime; int arriveMonth; int arriveDay; double arriveTime; char departAirport[SIZE]; char arriveAirport[SIZE]; ; }; class flightTrack { flightInfo data[SIZE]; int countIndex; char FileName[SIZE]; public: int loadFlights(); void addFlight(); bool srearchFlights(); void listFlights(); }; #endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started