Prompt the user for two characters. Output the movies that begin with those two characters.
What my goal was to use the already created string and use the first and second cell to compare to what the user inputs, but I get somewhat of an overloaded function.
Current code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct Movie
{
string name;
string year;
string genre;
};
int main()
{
string check[1];
Movie mlist[116792];
cout << "Begins-With Movie Finder" << endl;
cout << "Enter first character" << endl;
cin >> check[0];
cout << "Enter second character" << endl;
cin >> check[1];
int counter2 = 0;
while(!data_store.eof())
{
if (check[0] == mlist[counter2].name[0])
{
bool check1 = true;
}
else if (check[1] == mlist[counter2].name[1])
{
bool check2 = true;
}
if (check1 && check2)
{
cout << mlist[counter2].name << endl;
}
}
data_store.close();
return 0;
}
error:
E:\CS 111\2CS111\Problem Set Questions\PS9\PS9Q1_Two_characters.cpp|53|error: no match for 'operator==' in 'check[0] == mlist[counter2].Movie::name.std::basic_string<_CharT, _Traits, _Alloc>::operator[]<char, std::char_traits<char>, std::allocator<char> >(0u)'|