void searchFlight(cust flights[] ,int row)
{
clrscr();
cout << "Search for the flight you are looking for.\n";
string airport;
cout << "Enter Departing Flight : ";
cin >> airport; //error
for (int r=0;r<row;r++)
{
if (strnicmp(airport, flights[r].airport[20], strlen(airport) ==0) //error
{
clrscr();
cout << flights[r].name[20] <<endl;
cout << flights[r].airport[20] <<endl;
cout << flights[r].destination[20] <<endl;
cout << flights[r].ticket <<endl;
cout << flights[r].passangers <<endl;
cout << flights[r].opCost <<endl;
cout << flights[r].income <<endl;
cout << flights[r].netProfit <<endl;;
pressKey();
}
}
pressKey();
}
For the cin error:
error C2678: binary ‘>>’ : no operator found which takes a left-hand operand of type ‘std::istream’ (or there is no acceptable conversion)
For the strnicmp error:
error C2664: ‘strlen’ : cannot convert parameter 1 from ‘std::string’ to ‘const char *’
I have searched for solutions to this problem and could not fix it. Apologies if there is a similar post on here which could have solved my problems.
Add
#include <string>to your CPP file.Confirm that you have
#include <cstring>to your CPP file, and replace your call with:strnicmp(airport.c_str(), flights[r].airport[20], strlen(airport.c_str()) ==0.I suspect that
flights[r].airport[20]is also incorrect, but I can’t know because you didn’t post a complete program.If
cust::airportis declared likestd::string airport;, then you needflights[r].airport.c_str().If
cust::airportis declared likechar airport[20];, then you needflights[r].airport.