include stdafx include iostream include windows using namespace std in

 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 "stdafx.h"
#include "iostream"
#include "windows.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n;
char t = 'n';
LPCTSTR source1 = L"C:\\Somefolder\\file.txt";
LPCTSTR dest1 = L"E:\\folder\\file.txt";
LPCTSTR dest2 = L"C:\\folder\\file.txt";
LPCTSTR source2 = L"E:\\Somefolder\\file.txt";
LPCTSTR source;
LPCTSTR dest;
char *s = new char [10];
do {
t = 'n';
cout << "What do u want 2 do?\n";
cin >> s;
if (s[0] == 'w') {
source = source1;
dest = dest1;
cout << "Number of iterations\n";
cin >> n;
cout << (char)source << " will be written to " << (char)dest << " " << n << " times\n";
} else if(s[0] == 'r') {
source = source2;
dest = dest2;
cout << "Number of iterations\n";
cin >> n;
cout << (char)source << " will be read to " << (char)dest << " " << n << " times\n";
} else {
cout << "bad usage\n";
dest =L"test";
source = L"source";
break;
}
cout << "working\n";
for (int i = 0;i < n;i++) {
cout <<"i = " << i << endl;
BOOL flag = CopyFile(source,dest,0);
if (!flag) {
cout << "Error: " << GetLastError() << endl;
getchar();
break;
}
flag = DeleteFile(dest);
if (!flag) {
cout << "Error: " << GetLastError() << endl;
getchar();
break;
}
}
cout << "one more time? y/n\n";
cin >> t;
} while (t == 'y');
return 0;
}