Hi I'm trying to read in actors from a file that I got off IMDB and I wanted it to be searchable to whenever the user enters an actors name, the program would output the movies the actor has starred or been associated with. I've gotten the search function to work but the only problem is that it only prints out the first line after the actors name, I want it to print out all movies associated with him whether it be 5 or 10 lines or 50 who knows. This is what I have so far.
#include <iostream>
#include "imdb.h"
using namespace std;
int main()
{
string name;
IMDB actor;
cout << "Enter actors last name, first name: ";
getline(cin, name);
actor.setActorsName(name);
actor.load2010File();
return 0;
}
#include "imdb.h"
#include <fstream>
#include <vector>
IMDB::IMDB()
{
//ctor
}
IMDB::~IMDB()
{
//dtor
}
void IMDB::setActorsName(string actorsName)
{name = actorsName;}
void IMDB::load2010File()
{
string line;
// opens file
ifstream inputFile("actors.2010.list", ios::in);
// test if file exists
if(!inputFile)
cout << "Error opening actors.2010.list";
bool next = false;
while(!inputFile.eof())
{
getline(inputFile, line);
if(next)
{
getline(inputFile, line, '('); // parsed once a '(' is encountered
cout << line;
break;
}
if(line == name)
{
cout << "yes " << name << endl;
next = true;
continue;
}
}
inputFile.close();
}
any help would be appreciated.