-
Notifications
You must be signed in to change notification settings - Fork 2
/
Compare.c
69 lines (60 loc) · 1.59 KB
/
Compare.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*****************************************************************************************************************
*
* NAME : VINU CHARANYA ATHANGUDI PURUSHOTHAMAN
* PERSON # : 37648013
* PROGRAM ## : Compare.c
* HEADER FILE : osheaders.h
*
* DESCRIPTION : Program takes two arguments from the command line <Input File> <Output File>
* It Compares both the files character by Character and says if both files are same
*
* EXECUTION : ./Compare <Input File> <Output File>
*
* DATE : 25 JAN 2011
*
******************************************************************************************************************/
#include "osheaders.h"
int main(int argc, char **argv)
{
char * SourceFile;
char * OutputFile;
int t;
char c,c1;
t=0;
size_t fsource,fdest;
if(argc != 3)
{
printf("Please provide valid arguments of Source and Destination Files\n");
return 0;
}
SourceFile = argv[1];
OutputFile = argv[2];
FILE *finp,*fout;
finp= fopen(SourceFile, "r");
fout= fopen(OutputFile, "r");
fseek(finp,0,SEEK_END);
fsource = ftell(finp);
rewind(finp);
fseek(fout,0,SEEK_END);
fdest = ftell(fout);
rewind(fout);
while(!feof(finp) )
{
c= getc(finp);
c1= getc(fout);
if(c!=c1)
{
t=1;
}
}
printf("\nNumber of Character in Input File\t: %lu\n",fsource);
printf("\nNumber of Character in Output File\t: %lu\n",fdest);
if (t==0)
{
printf("\n\n*****Success Your Input and Output files are similar*****\n\n");
}
else
{
printf("\n\n*****Failure. Your Input and Output Files are different*****\n\n");
}
}