Hello everyone,
I am getting this error
std::vector<std::basic_string<char> >) (unsigned int&)'|
and cannot figure out what I am doing wrong. There might be more mistakes but cannot pass this error message so I couldn't test anything yet.
Thanks for reading.Code:#include <iostream> #include <fstream> #include <vector> using namespace std; int main() { // Create an input file ifstream inputFile; inputFile.open("WorldSeriesWinners.txt"); // Check if the files exists or not, if(!inputFile){ cout << "File couldn't be found!" << endl; return 0; } // Read the contents of the file into a vector vector<string> worldSeries; string input; while(inputFile >> input) { worldSeries.push_back(input); } // Close the file inputFile.close(); // Get a team name from the user string userTeam; cout << "Enter a team name that you would like to check for: " << endl; getline(cin, userTeam); int wins = 0; // Accumulator string quantity; // Find how many times user's team won the series for for(unsigned int index = 0; index < worldSeries.size(); index++) { if(worldSeries(index) == userTeam) // Error is here!!! { wins++; } } // Display the results cout << userTeam << " won the series for " << wins << (wins > 0 ? " times." : " time."); }