使用C++的fstream类来实现
char* filename = "C:\\grldr.mbr";//须复制文件路径 int len = strlen(filename); while( *(filename+len-1)!='\\'){ len--; }//获得文件名 char temp[32]; strcpy(temp,(filename+len)); for (int i = 0; i<=strlen(temp); i++) { char ch = temp[i]; if ( ch>='a'&&ch<='z') { temp[i] -= 'a'-'A'; } }//修改大小写 ofstream outfile;//创建文件 outfile.open(temp,ios::out|ios::binary); ifstream infile;//读入待复制文件 infile.open(filename,ios::in|ios::binary); if (infile.is_open()) { char ch; infile.get(ch); while(!infile.eof()){//eof文件结束标志 outfile<<ch; infile.get(ch); } infile.close(); } outfile.close();
转载于:https://blog.51cto.com/purplexuan/1175745