标签:
问题描述:
要求把第二个文件拼接到第一个文件的末尾。 如把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; }
一周内请勿抄袭! 以防作业雷同!
标签:
原文地址:http://www.cnblogs.com/acm1314/p/4557759.html