从命令行复制C ++文件 [英] copy file in C++ from command line
本文介绍了从命令行复制C ++文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
对不起我糟糕的英语
i想要一个从命令行获取多个文件名的程序(myProject.exe file1.txt file2.txt file3.txt)并将它们复制到其他路径exp:D:\ dest中的文件名是大写
i希望它为我的老师tommarow如果你能为我写那个。
请帮忙。
[已添加]
这里是代码
hi
i''m sorry for my poor english
i want a program that get many file name from command line (myProject.exe file1.txt file2.txt file3.txt) and copy them in other path exp: D:\ that file name in dest is Upper case
i want it for my teacher tommarow if you can please write that for me.
please help.
[added]
here is the code
#include <iostream.h>
#include <stdio.h>
#include <fstream>
#include <ctype.h>
int main(int argc, char* argv[],char* argvNew[])
{
for (int j=1;j<argc;j++) {
for(int i=0;argv[j][i];i++)
{
argv[j][i] = toupper(argv[j][i]);
}
char buffer[2560];
ifstream f1 (argv[j],fstream::binary);
ofstream f2 (strcat("d:\\",argv[j]) ,fstream::trunc|fstream::binary);
f2<<f1.rdbuf();
}
}
[-added]
[-added]
推荐答案
我建议你开始编码并创建你的程序。这里没有人会为你做功课。
I suggest you start coding and get your program created. No one here is going to do your homework for you.
主要功能的定义是:
The definition of main function would be:
int main(int argc,char **argv)
创建一个可以复制文件部分的函数
然后循环调用该函数。
例如:
create a function that would do the copy file part
then call the function in loop.
example:
int main(int argc, char **argv)
{
for(int i=0;i<argc;i++)>
{
function_to_copy(argv[i],copied_path);
}
}
这篇关于从命令行复制C ++文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文