C:\Users\Little_Chick\Documents\Visual Studio 2005\Projects\BT4-A\BT4-A\main.

cpp

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

// Bai 4a: Vi tri cac dong code khong doi nhung moi dong khac nhau dau cach , dau
tab va enter
// huahongquan2007
#include <stdio.h>
long fsize(char * fname)
{
FILE *fp = fopen(fname,"rb");
if(fp != NULL )
{
fseek(fp,0,SEEK_END);
long size= ftell(fp);
fclose(fp);
return size;
}
return -1;
}
void main(int argc, char * argv[])
{
FILE * fp1 = fopen (argv[1],"rb");
FILE * fp2 = fopen (argv[2],"rb");
if(argc != 3)
{
printf("Syntax error : %s <file 1 > < file 2>", argv[0]);
}
if( fp1 == NULL )
{
printf("CANNOT OPEN FILE %s \n",argv[1]);
return;
}
if( fp2 == NULL )
{
printf("CANNOT OPEN FILE %s \n",argv[2]);
return;
}
while(!feof(fp1))
{
char data1,data2;
do
{
fread ( & data1, 1 ,1, fp1);
}
while( data1 == ' ' || data1 == 13 || data1 == 10 || data1 == 11 || data1 ==
9);

46
47
48
49
50
51
52
53
54
55

Monday, April 04, 2011 2:55 PM

do
{
fread ( & data2, 1 ,1, fp2);
}
while( data2 == ' ' || data2 == 13 || data2 == 10 || data2 == 11 || data2 ==
9);
if(data1 != data2 ) {printf("HAI FILE KHAC NHAU");
return ;}
}
-1-

C:\Users\Little_Chick\Documents\Visual Studio 2005\Projects\BT4-A\BT4-A\main.cpp

56
57
58
59

Monday, April 04, 2011 2:55 PM

printf("HAI FILE GIONG NHAU HOAN TOAN ");
fclose(fp1);
fclose(fp2);
}

-2-

Sign up to vote on this title
UsefulNot useful