I want to check if the value the user inputs is in the file that i have opened.
i am doing a taxi booking system.
user input = userTime (the time the user wants picking up from the taxi)
i am trying to check if this time is already next to all of the drivers (4)
in my file i have
driver name,
driver number,
time booked
if userTime is the same as time booked on all 4 drivers in the file then the system will say no drivers available for the time required
it is in 24hr time so userTime would match exactly to the file contents in time booked. e.g 1200 = 12pm
please help soon thank you p.s. i am new to c++
here is my code so far, a function. it says 'expression must have pointer to object type' on the second instance of cab. and also the two [i]s on the cab.timeBooked 's. what is wrong with it please ?
struct Driver
{
string firstName;
double number;
int timeBooked;
};
struct Driver cab;
void searchDrivers()
{
cout << "\nSearching for drivers..." << endl;
ifstream inFile;
inFile.open("drivers.txt");
if (!inFile)
{
cout << "error reading file";
}
else
{
for (int i = 0; i < 4; i++)
{
inFile >> cab.firstName[i] >> cab.number[i] >> cab.timeBooked[i];
if (userTime2 == cab.timeBooked[i])
{
cout << "unavailable" << endl;
}
else
{
cout << "car available" << endl;
driverIndex = i;
confirmBooking();
}
}
}
}