// テキストファイルの入出力 // ifstream と ofstrem // input.txt の内容はスペース(改行でもいい)区切りで整数を3つ記述するだけ // の簡単なものです。適当に作成して下さい。 #include <iostream> #include <fstream> using namespace std; int main( ) { ifstream in( "input.txt" ); // 入力ストリーム if ( !in ) { cout << "can't open file" << endl; return 1; } ofstream out( "output.txt" );// 出力ストリーム if ( !out ) { cout << "can't open file" << endl; return 1; } for ( int i = 0; i < 3 ; i++ ) { int j; in >> j ; out << j; } // クローズ in.close( ); out.close( ); return 0; } /* >>演算子は White Space を読み飛ばすのでご注意。 */ // end of file