問題及代碼:
/*
*Copyright (c) 2016,煙臺大學計算機學院
*All rights reserved.
*文件名稱:zwj.cpp
*作 者:張偉晶
*完成日期:2016年6月17日
*版 本 號:v1.0
*
*問題描述:閱讀程序
*輸入描述:
*程序輸出:
*/
#include <iostream>
#include <fstream>
#include<cstring>
using namespace std;
int main()
{
ifstream readFile;
ofstream writeFile;
char ch[100];
readFile.open("a.txt", ios::in);
writeFile.open("b.txt", ios::out);
while (!readFile.eof())
{
readFile.getline(ch,100,'\n');
writeFile.write(ch,strlen(ch));
writeFile.write("\n",1);
}
readFile.close();
writeFile.close();
cout << "Finish!" << endl;
return 0;
}
運行結果:
知識點總結:
文件輸入輸出