How to skip names in File?

  c++, file

I am writing a code to read a text file from my computer and I need to successfully skip names that are italian. The text file follows the pattern of composer name, then opera name, then language.

This is my code so far:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
ifstream fileIn;
ofstream fileOt;
fileOt.open(
"c://Users/myname/Desktop/operas.txt");

fileIn.open(
"c://Users/myname/Desktop/operas.txt");
string composer, opera, language;
while (getline(fileIn, composer)) {
    
    getline (fileIn, language);
    if (language != "Italian"){
        
        fileOt<<composer<<endl;
        getline(fileIn, opera);
        fileOt<<opera<<endl;
}
}
fileIn.close();
fileOt.close();

return 0;

}

Am I on the right track? For some reason my computer does not allow me to see if my code is running, however it is successfully being built. Will this output composer names and opera names that are not italian?

Source: Windows Questions C++

LEAVE A COMMENT