io20_6.01.c

来自「C++ Primer(第三版)的随书源代码」· C语言 代码 · 共 31 行

C
31
字号
// #include <fstream>
#include <fstream.h>

/**
 **
 stanl@john:d.ch20 222 : cat input
 23 109 45 89 6 34 12 90 34 23 56 23 8 89 23

 stanl@john:d.ch20 223 : a.out < input
 stanl@john:d.ch20 224 : cat copy.out
 23 109 45 89 6 34 12 90 34 23 56 23 8 89 23
 **
 **/


int main()
{
    // open a file copy.out for output
    ofstream outFile( "copy.out" );

    if ( ! outFile ) {
        cerr << "Cannot open ``copy.out'' for output\n";
        return -1;
    }

    char ch;
    while ( cin.get( ch ) )
	    outFile.put( ch );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?