C在Windows上,代码复制文件不起作用

Jam*_*eto 3 c windows cmd copy

我有这段代码; 它直接写入参数时有效system(),如果将参数传递给它则不起作用.有什么帮助吗?

char dest[100];
char file[50];
char dir[100];

printf("Enter source path: ");
scanf("%s", dir);

printf("Enter filename: ");
scanf("%s", file);

printf("Enter destination path: ");
scanf("%s", dest);

system("move \"c:\\users\\putty.exe\" g:\\ \n" );  /* <--works        */
system("move \"%s%s\" %s", dir,file,dest);         /* <--doesn't work */
Run Code Online (Sandbox Code Playgroud)

Bab*_*avi 5

你可以试试这个

char dest[100];
char file[50];
char dir[100];
char command[300];
printf("Enter source path: ");
scanf("%s", dir);
printf("Enter filename: ");
scanf("%s", file);
printf("Enter destination path: ");
scanf("%s", dest);
sprintf(command,"move %s%s %s", dir,file,dest);  
system(command); 
Run Code Online (Sandbox Code Playgroud)