fail.cpp

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C++ 代码 · 共 19 行

CPP
19
字号
#include <iostream.h>
#include <fstream.h>

void main( void ) {

    fstream    test ( "temp.txt", ios::in|ios::out );  // S1

    /* S2: fstream    test ("temp.txt", ios::in);
       Compare the results by using S2 instead of S1  */

    if( !test.bad() ) {
        test << "Hello my world!" << endl;
        cout << "\"temp.txt\" is created." << endl;
    }
    if( test.fail() ) {
        cout << "The previous operation on the stream fails!" << endl;
    }
}

⌨️ 快捷键说明

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