首页 > 编程语言 > 详细

c++实现两个文件的拼接。

时间:2015-06-07 10:56:27      阅读:1508      评论:0      收藏:0      [点我收藏+]

  问题描述:

  要求把第二个文件拼接到第一个文件的末尾。 如把file2 拼接到 file末尾。 (直接复制一下不久行了嘛! 但是老师非让编程, 真是蛋疼!!)。例如:

file1: I am not responsible of this code. They made me write it, against my will.   file2: When I wrote this, only God and I understood what I was doing. Now, God only kowns.   拼接后: file1: I am not responsible of this code. They made me write it, against my will. When I wrote this, only God and I understood what I was doing. Now, God only kowns.  

知识点: 文件流类。

 

#include<iostream>
#include<fstream>
using namespace std;

const int maxn = 1000+10;

int main()
{
    char str[maxn]; 
    ifstream cin("file2.txt");
    ofstream cout("file1.txt", ios::app);
    while(cin.getline(str, maxn))
    {
        cout<<str<<endl;
    }
    return 0;
}

一周内请勿抄袭! 以防作业雷同!

c++实现两个文件的拼接。

原文:http://www.cnblogs.com/acm1314/p/4557759.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!