#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
usingnamespace std;
int main ()
{
string STRING;
ifstream infile;
infile.open ("E:\\sample_exts\\fileA.txt");
int a=0;
string previousLine="";
while(a<1) // To get you all the lines.
{
getline(infile,STRING); // Saves the line in STRING.
if (STRING != previousLine)
{
previousLine=STRING;
cout<<STRING<<endl; // Prints our STRING.
}
}
infile.close();
system ("pause");
getch();
}
To read from a second file, all you need to do is create another ifstream variable, and open a file. Its exactly the same as infile but another name. e.g:
1 2 3 4 5 6 7 8 9 10
ifstream infile;
ifstream anotherinfile;
infile.open ("E:\\sample_exts\\fileA.txt");
anotherinfile.open ("E:\\sample_exts\\fileB.txt");
//you can now read from infile, or anotherinfile.
infile.close();
anotherfile.close();
You can do this with more files if you wish, you just need to change the variable name (infile, anotherinfile, ect).
I'm going to point you to these pages for finding the info on how to check strings against each other.
Just ask if you need more help.