home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "string.h"
- #include "stdlib.h"
-
- /* Same - Copyright (c) 1990 by Daniel Zenchelsky */
- /* */
- /* Takes two sorted files and reports only those lines that match. */
- /* Case does not matter. */
- /* */
-
- extern char VersionString[];
-
- char *upper();
-
- main(argc,argv)
- int argc;
- char **argv;
- {
- char data1[257],data2[257],udata1[257],udata2[257];
- FILE *file1,*file2;
- int cmp;
-
- printf("Same - Version 1.0 - %s\n",VersionString);
- printf("Copyright (c) 1990 by Daniel Zenchelsky.\n\n");
-
- if (argc != 3)
- {
- printf("Usage: Same File1 File2\n");
- exit(10);
- }
-
- if ( (file1=fopen(argv[1],"r"))==NULL )
- {
- printf("Error opening file %s\n",argv[1]);
- exit(10);
- }
- if ( (file2=fopen(argv[2],"r"))==NULL )
- {
- printf("Error opening file %s\n",argv[2]);
- exit(10);
- }
-
- fgets(data1,255,file1);
- fgets(data2,255,file2);
-
- while (!feof(file1) && !feof(file2))
- {
- upper(data1,udata1);
- upper(data2,udata2);
-
- cmp = strcmp(udata1,udata2);
- if (cmp==0) printf("%s",data1);
- if (cmp<=0) fgets(data1,255,file1);
- if (cmp>=0) fgets(data2,255,file2);
- }
-
- fclose(file1);
- fclose(file2);
-
- }
-
- char *upper(in,out)
- char in[];
- char out[];
- {
- int count;
- for (count=0;in[count]!=NULL;count++)
- out[count]=toupper(in[count]);
- out[count]=NULL;
- return(out);
- }
-