compare 2 files?
Posted on 2004-04-28
I'm trying to compare the values in two different input files and based on the matching of a certain value I output it to another file.
If my file1 has 10 rows and my file2 has 5 rows I want the first row of file1 to compare with all the rows in file 2 and then go to the 2nd row of file 1 and compare with all the rows in file 2 and so on.. .
The code I have written does not do exactly what I want. Can someone correct my while and if loops.
ps: my tokenize function works well!
ifp1 = fopen("c:/input1.txt", "r");
ifp2 = fopen("c:/input2.txt", "r");
ffp = fopen("c:/out.txt","w");
while(fgets( linein1, sizeof( linein1 ), ifp1 ) != NULL)
TokenCount1 = tokenize1( linein1, ",\n", tokens, X_TOKEN1 );
if(fgets( linein2, sizeof( linein2 ), ifp2 ) != NULL)
TokenCount2 = tokenize2( linein2, ",\n", token, X_TOKEN2 );
if (( TokenCount1 == 21 ) && (TokenCount2 == 5))
fprintf(ffp, "Service Date ..........<%s>\n",tokens);
return( 0 );