c++ 搜索读取文本另写入

来源:互联网 发布:求质数的最优算法 编辑:程序博客网 时间:2024/05/18 13:48

在文件夹中有1.txt-99.txt,一共99个文件,我输入55,就会打开55.txt,同时复制到b.txt

#include<iostream>#include<fstream>using namespace std;int main(){  char fileName[20],suffix[]=".txt";  cin>>fileName;  strcat(fileName,suffix);  ifstream  in(fileName,ios::binary);  ofstream  out("b.txt",ios::binary);  char temp;  while(in.peek()!=-1)  { in.read(&temp,sizeof(temp)); out<<temp;  }  system(fileName);   return 0;}

原创粉丝点击