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
| #include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;
bool Find(ifstream &f)
{
char t,s;
int pos;
int size;
f.seekg(0,ios_base::end);
size = f.tellg();
f.seekg(0,ios_base::beg);
pos = 0;
while(pos!=size)
{
f>>t;
pos++;
while(size!=f.tellg())
{
f>>s;
if(t == s)
{
return true;
}
}
f.seekg(pos,ios_base::beg);
}
return false;
}
void main()
{
cout<<"Enter file patch"<<endl;
char* pFilePatch = new char[256];
cin>>pFilePatch;
ifstream file;
file.open(pFilePatch,ios_base::binary);
if(file.is_open())
{
if(Find(file))
{
printf("OK\n");
}
else
{
printf("NO\n");
}
file.close();
}
else
{
printf("File not open\n");
}
delete [] pFilePatch;
cout<<"Press any key to exit..."<<endl;
getch();
} |
|
надо проще, строк в 10-15.