Hello everyone
I have written a small c++ program where two files are compared line by line and in case the lines are different, the differing ones are put into a report.txt document.But its not working right!
The first few lines which are same are not put into the report.txt, but all the remaining ones, be it same or not are being copied!
The following is my code
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
using namespace std;
void main()
{
ifstream Ifile1("D:\\file1.txt");
ifstream Ifile2("D:\\file2.txt");
ofstream out("D:\\Report.txt");
char Line1[256],Line2[256];
int check=0;
system("pause");
while (Ifile1.getline (Line1,256) && Ifile2.getline (Line2,256))
{
check=strcmp(Line1,Line2);
if(check!=0)
out<<Line2<<endl;
}
out.flush();
out.close();
}
P.S. I wrote the program so that if the lines are differing only the lines from the second file are copied.
Please help with my problem! I need to get this done asap!
Thanks in advance