/* diff.c  09-Jan-89  A.J.Travis *//* * 'line by line' file comparison */#include <stdio.h>#define SAME 0FILE *fp1, *fp2;char *bp1, *bp2;int c1, c2;int eof1, eof2;int n;char buf1[BUFSIZ];char buf2[BUFSIZ];int main(argc, argv)int argc;char *argv[];{	if (argc != 3) {		fprintf(stderr, "usage: diff file1 file2\n");		exit(-1);	}	if ((fp1 = fopen(argv[1], "r")) == NULL) {		fprintf(stderr, "diff: can't open %s\n", argv[1]);		exit(-1);	}	if ((fp2 = fopen(argv[2], "r")) == NULL) {		fprintf(stderr, "diff: can't open %s\n", argv[2]);		fclose(fp1);		exit(-1);	}	n = 0;	while (++n) {		eof1 = (fgets(buf1, BUFSIZ, fp1) == NULL);		eof2 = (fgets(buf2, BUFSIZ, fp2) == NULL);		if (eof1 & eof2)			break;		if (eof1 & (eof2 == 0)) {			printf("diff: end of file on %s\n", argv[1]);			break;		}		if (eof2 & (eof1 == 0)) {			printf("diff: end of file on %s\n", argv[2]);			break;		}		if (strcmp(buf1, buf2) != SAME)			printf("%d:\n< %s> %s", n, buf1, buf2);	}	fclose(fp1);	fclose(fp2);	exit(0);}