第15周程序阅读(1)

/*
* Copyright (c)2013, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: array.cpp
* 作    者:   李中意
* 完成日期:2014  年 6 月 3 日
* 版本号: v1.0
* 输入描述:无
*/

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream readFile;//ifstream  输入文件流类
    ofstream writeFile;//ofstream 输出文件流类
    char ch;
    readFile.open("a.txt", ios::in);//调用成员函数open,即打开该文件
    writeFile.open("b.txt", ios::out);
    while (readFile.get(ch))
//readFile.get(ch)作用是从输入流中读取一个字符,赋给字符变量ch。如果读取成功则函数返回非0数(真),失败返回值为假。
    writeFile.put(ch);//用流成员函数输出字符ch
    readFile.close();//关闭文件
    writeFile.close();
    cout << "Finish!" << endl;
    return 0;
}

你可能感兴趣的:(第15周程序阅读(1))