Need help...constant error.

:(
Using Code::Blocks...
Current objective:

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];

ifstream data_store;
data_store.open("movie_database.txt");

if(!data_store)
{
cout << "Could not find file..." << endl;
return 0;
}

bool check1 = false;
bool check2 = false;

int counter = 0;
while(!data_store.eof())
{
string name, year, genre;
getline(data_store, name);
getline(data_store, year);
getline(data_store, genre);
mlist[counter].name = name;
mlist[counter].year = year;
mlist[counter].genre = genre;

cout << mlist[1].name[1] << mlist[1].name[0] << endl;

}

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)'|
Last edited on
check[0] is a std::string.
mlist[counter2].name[0] is a char.
Topic archived. No new replies allowed.