I am writing a program that when run from the terminal in linux (redhat), it is to take in 3 filenames of txt files, the first 2 file are used to compare lines of text to see if they are different if they are then they are wrote to the 3rd file, the program is to then prinf the contents of the third file to the screen.

I have not been able to test the program as my other machine is down and i don't get it back till friday, so i can't test it, so i am having to write it by hand.

Can anyone help me to see if this will work or if there

/************************************************** **/
/* Author: Alisdair Comb */
/* Filename: checker.c */
/* Date: 27/07/01 */
/* Program: File Checker v1.0a */
/* */
/************************************************** **/
/* About the Program */
/* This Program is designed to take lines of text */
/* from 2 seperate files (txt) and compare the */
/* lines of text, if they are different, then */
/* the line of text will be wrote to a third */
/* file, after which it will display the contents */
/* of that file. */
/************************************************** **/

#include <stdio.h>
#include <string.h>

#define MAX_LEN 80;

int reperror, x;
FILE *fn1, *fn2, *fn3;
char buf1[MAX_LEN];
char buf2[MAX_LEN];

int main(int argc, char *argv[])
{

/*
-------------------------------------------------------------------------
Check to see that 3 command arguments were entered along with the program
executable file.
-------------------------------------------------------------------------
*/

reperror = 0;

if (argc == 3)
{
printf(" You Entered a correct amount of information");

if((fn1 = fopen(argv[1] ,"r")) = NULL)
{
printf("There was an error with File 1");
reperror++;
}
else
{
printf("File 1 Checked out okay");
}

if((fn1 = fopen(argv[2] ,"r")) = NULL)
{
printf("There was an error with File 2");
reperror++;
}
else
{
printf("File 2 Checked out okay");
}

if((fn1 = fopen(argv[2] ,"w")) = NULL)
{
printf("There was an error with File 3");
reperror++;
}
else
{
printf("File 3 Checked out okay");
}
/* If there has been any errors the program terminates*/
if (reperror > 0);
{
printf(" Sorry There was a problem with opening the files, please check/n ");
printf(" Filenames using error messages above!!! ");
prinft(" program terminated/n ");
exit(1);
}
else
{
printf("All the files check out okay, program will continue..../n");
}


}
else
{
printf("There was and error, you did not enter enough");
printf("Filenames from command prompt please check and");
printf("correct");
exit(1);
}

/*
-------------------------------------------------------------------------

-------------------------------------------------------------------------
*/

do
{
// Gets a line of text from each txt file usally upto end of line char
// or reaches the buffer
fgets( buf1, MAX_LEN, argv[1])
fgets( buf2, MAx_LEN, argv[2])

x = strcmp(buf1, buf2)
if ( x != 0)
{
printf("File 1: Line n :%s \n",buf1);
printf("File 2: Line n: %s \n",buf2);
fprintf(argv[3], "%s \n %s \n", buf1, buf2 );
}
} while ( argv[1] != EOF &| argv[2] != EOF)
// While file 1 and or file 2 is not EOF


// With the files check print whats in the text file 3
if ( argv[3] == Null)
printf("The File was empty!!!");
else
printf("%s" argv[3]); // Print contents of txtfile 3 to screen

return 0;
}

I am usure about the while loop, not sure if you can do a and or situation. Also stinking i am not sure if i need to empty buf1 and buf2, do i need to.

Thanks for any help I am most grateful.

-ali