Another assignment, another due date, another exams, thats how I describe my life these days

Im trying to read a date from the user and compare it with the date in the file and if the date is foung I have to print some user details... so my problem is I cant get that right, I dont know how to do it I tryied all the combinations but none is working, my compiler just complain in my strange code that it never really come across in its life time,

PLease guys all I need is code that is related to that because of some reasons I cant post my code here, just anything that is reading from the user and compare to the values from the file

Any help will be highly appreciated
Thanx

Read the string in the file using "getline" and maybe use something like "strcmp" to compare it to the user input

I have two files and have to compare dates and flight-number to both files and if found I have to accept passenger details,

The isFlightAvailable is a function where I have my boolean which search for the date from another class, hope thats clear enough

infile.open("file.dat");
file.open("onfile.dat");
//Accept a date and flight number
cout << "Enter date:  ";
cin >> date;
cout << endl;
cout << "Flight Num:  ";
cin >> flight;
//Using a loop, call a method which will check if a flight for that Date and Flight Number is available
//HINT: as soon as a match is found, stop the loop
for(count = 0; count < Size; count++)
{
    if(date == CapeFile >> date && date == DurbsFile >> date)
     {
          B1[count].isFlightAvailable(date);
     }
	
	//If a match is found
	if(B1[count].isFlightAvailable(date))
	{
	      //Accept the passenger detail
                }
}

if(date == CapeFile >> date && date == DurbsFile >> date) I am having error here and I know thats so out of C++ syntax rule I was just trying anything that could possible work

I forgot to mention it....Accepting the passenger's details shouldnt be the problem, My problem is to get the date and the flight number from those files and compare them with the ones that user entered

> if(date == CapeFile >> date && date == DurbsFile >> date)
C++ lets you combine a lot of things, but this is a little too terse. ;) You need to read the file data separately and then compare it:

for(count = 0; count < Size; count++)
{
  Date capeDate;
  Date durbsDate;

  CapeFile >> capeDate;
  DurbsFile >> durbsDate;

  if(date == capeDate && date == durbsDate)
  {
    B1[count].isFlightAvailable(date);
  }
	
  //If a match is found
  if(B1[count].isFlightAvailable(date))
  {
    //Accept the passenger detail
  }
}

Now tell me Ed What are you doing here

Date capeDate;
Date durbsDate;

> Now tell me Ed What are you doing here
Edward is speculating wildly about what the type of your date variable is. Your code doesn't specify whether it's a string, a custom date class, or something else, so Ed had to guess. Replace "Date" with whatever type you're actually using.

This article has been dead for over six months. Start a new discussion instead.