- #include <windows.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void main()
- {
- char cmd[100]={"xcopy /e "},direct[100]={0},dest[100]={0}; // xcopy /s的意思是复制目录和子目录,除了空的。 /e 空的目录也会被拷贝进去
- printf("输入要复制的文件夹: 如:C:\\\windows 或 C:\\\Documents and Settings\n");
- gets(direct);
- printf("输入要复制到哪里: 如:C:\\\windows 或 C:\\\Documents and Settings\n");
- gets(dest);
- strcat(cmd ,direct);
- strcat(cmd ," ");
- strcat(cmd ,dest);
- system(cmd);
- }
转载于:https://blog.51cto.com/591819849/1101487