fileone.txt
How to apply for financial aid? (file1var)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
file2two.txt
How to apply for financial aid? (file2var)
By going to the financial aid office (file2var2)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
How do I check condition if a variable(f1var) for file 1(fileone.txt) is equal to the first variable(f2var) in file 2(filetwo.txt). And if they are equal, I am trying to output the 1st variable(f2var) and 2nd variable(f2var2) of file 2(filetwo.txt) as an output.
#include <iostream>
#include <string>
#include <fstream>
#include<stdlib.h>
#include<string.h>
#include<ctime>
using namespace std;
int main()
{
string f1var;
string f2var, f2var2;
int counter;
ifstream y("fileone.txt");
ifstream x("filetwo.txt");
while((getline(y,f1var) && getline(x,f2var);getlin(x,f2var2)
{
if(f1var==f2var)
{
counter=1;
}
}
y.close();
x.close();
if(counter==1){
cout<<f2var<<f2var2<<endl;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire