#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; }