c++如何从txt文件读取内容到另外一个txt里面
2个回答
展开全部
//#include "stdafx.h"//vc++6.0加上这一行.
#include <iostream>
#include <fstream>
using namespace std;//
void main(void){
ifstream frp;
ofstream fwp;
frp.open("oldfile.txt",ios::in);
fwp.open("newfile.txt",ios::out | ios::trunc);
if(frp==NULL || fwp==NULL){
cout << "Open file failure...\n";
if(frp) frp.close();
exit(0);
}
char ch;
while(!frp.eof()){
ch=frp.get();
fwp.put(ch);
}
frp.close();
fwp.close();
}
#include <iostream>
#include <fstream>
using namespace std;//
void main(void){
ifstream frp;
ofstream fwp;
frp.open("oldfile.txt",ios::in);
fwp.open("newfile.txt",ios::out | ios::trunc);
if(frp==NULL || fwp==NULL){
cout << "Open file failure...\n";
if(frp) frp.close();
exit(0);
}
char ch;
while(!frp.eof()){
ch=frp.get();
fwp.put(ch);
}
frp.close();
fwp.close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询