Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

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

$
0
0

在文件夹中有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;

}

作者:a771948524 发表于2013-6-3 21:14:20 原文链接
阅读:24 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>