#include "stdafx.h" #include <iostream> #include <stdlib.h> #include <conio.h> using namespace std; int main() { system("color 02"); system("xcopy 'C:\text.txt' 'F:\hack ' /E"); _getch(); return 0; } 

Closed due to the fact that the essence of the issue is incomprehensible by the participants Abyx , cheops , Harry , Kromster , αλεχολυτ Dec 2 '17 at 9:43 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • what is the actual question? - Abyx
  • displays an "invalid number of parameters" to the console - Ugnius Mkrthcan Nov.

2 answers 2

I think you did not take into account that the backslash inside string literals has a special meaning. Or shield them:

 "xcopy 'C:\\text.txt' 'F:\\hack ' /E" 

either use raw literals:

 R"(xcopy 'C:\text.txt' 'F:\hack ' /E)" 

Now, from the point of view of the command interpreter, you need to remove the single quotes, replacing them with double quotes, and remove the extra parameter /E (since you are copying one file). Since double quotes need to be escaped, you get this:

 "xcopy \"D:\\text.txt\" \"D:\\hack\"" 

or

 R"(xcopy "D:\text.txt" "D:\hack")" 
  • still does not work (( - Ugnius Mkrthcan Nov.
  • and single quotes are probably not ok - Abyx Nov.
  • @Abyx: Strange, why not ok? Or do you mean from the point of view of the command interpreter? - VladD
  • I do not know, I have never used single quotes in cmd.exe - Abyx
  • @Abyx: I tried, and the truth does not work. - VladD

Try this:

  system("xcopy C:\\text.txt F:\\hack /E"); 
  • simply the best!!!! - Ugnius Mkrthcan Nov.