examples/io/write2.ck
raw| 1 | // filename |
| 2 | "write2.txt" => string filename; |
| 3 | // instantiate a file IO object |
| 4 | FileIO fout; |
| 5 | // open for write (default mode: ASCII) |
| 6 | fout.open( filename, FileIO.WRITE ); |
| 7 | |
| 8 | // test |
| 9 | if( !fout.good() ) |
| 10 | { |
| 11 | cherr <= "can't open file for writing..." <= IO.newline(); |
| 12 | me.exit(); |
| 13 | } |
| 14 | |
| 15 | // write some stuff |
| 16 | fout.write( 1 ); |
| 17 | fout.write( 2 ); |
| 18 | fout.write( "boo" ); |
| 19 | |
| 20 | // close the thing |
| 21 | fout.close(); |
| 22 | |
| 23 | |
| 24 | <<< "file written:", filename >>>; |