// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // copyfile.cfa -- // // Author : Peter A. Buhr // Created On : Tue Jul 16 16:47:22 2019 // Last Modified By : Peter A. Buhr // Last Modified On : Tue Jul 16 16:48:16 2019 // Update Count : 1 // #include int main( int argc, char * argv[] ) { ifstream & in = stdin; // default files ofstream & out = stdout; try { choose ( argc ) { case 2, 3: open( in, argv[1] ); // open input file first as output creates file if ( argc == 3 ) open( out, argv[2] ); // only open output if input opens as output created if nonexistent case 1: ; // use default files default: exit | "Usage [ input-file (default stdin) [ output-file (default stdout) ] ]"; } // choose char ch; out | nlOff; // turn off auto newline in | nlOn; // turn on reading newline for () { // read all characters in | ch; if ( eof( in ) ) break; // eof ? out | ch; } // for } finally { close( in ); // stdin, stdout are never closed close( out ); } // try } // main // Local Variables: // // tab-width: 4 // // compile-command: "cfa copyfile.cfa" // // End: //