Hi,
I am comparing two file to find if they have common strings. My program is not doing that and I cannot figure out the reason. Any help is appreciated. Following is my code:
int main()
{
FILE *inf1 = fopen("file1.txt","r");
FILE *inf2 = fopen("file2.txt","r");
int numcols = 11;
char line1[numcols], line2[numcols];
while(fgets(line1, (numcols+1), inf1))
{
while(fgets(line2, (numcols+1), inf2))
{
if(line1 == line2)
{
cout << "Found a matching line" << "line1 = " << line1 << endl;
break;
}
}
rewind(inf2);
}
return 0;
}
Following are my file1.txt and file2.txt
file1.txt
---------------
1 0 2 2 0 1
1 1 2 2 1 1
file2.txt
-------------
0 0 0 0 0 0
0 0 0 0 0 1
1 0 2 2 0 1
1 1 2 2 1 1
Thanks