diff --git a/cp/Debug/test.txt b/cp/Debug/test.txt new file mode 100644 index 0000000..a8a9406 --- /dev/null +++ b/cp/Debug/test.txt @@ -0,0 +1 @@ +this is a test \ No newline at end of file diff --git a/cp/cp/main.cpp b/cp/cp/main.cpp index e69de29..ccd43d5 100644 --- a/cp/cp/main.cpp +++ b/cp/cp/main.cpp @@ -0,0 +1,33 @@ +#include + +void WriteStr(const char * str) +{ + HANDLE stdout2 = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD byteswritten; + int length = 0; + const char * cpyptr = str; + while(*cpyptr != 0) + { + cpyptr++; + length += 1; + } + WriteFile(stdout2, str, sizeof(str), &byteswritten, NULL); +} + +int main(int argc, char * args[]) +{ + WriteStr("abc"); + if (argc != 2) + { + WriteStr("Please enter two parameters - cp src dst"); + } + + HANDLE hsrc = CreateFileA(args[1], GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (GetLastError() == ERROR_FILE_NOT_FOUND) + { + WriteStr("Could not find file!"); + return 0; + } + + +} \ No newline at end of file