ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 29d618e was
29d618e,
checked in by Peter A. Buhr <pabuhr@…>, 4 years ago
|
formatting
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // copyfile.cfa -- |
---|
8 | // |
---|
9 | // Author : Peter A. Buhr |
---|
10 | // Created On : Fri Jun 19 13:44:05 2020 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Sat Aug 15 15:00:48 2020 |
---|
13 | // Update Count : 6 |
---|
14 | // |
---|
15 | |
---|
16 | #include <fstream.hfa> |
---|
17 | #include <exception.hfa> |
---|
18 | |
---|
19 | int main( int argc, char * argv[] ) { |
---|
20 | ifstream in = stdin; // copy default files |
---|
21 | ofstream out = stdout; |
---|
22 | |
---|
23 | try { |
---|
24 | choose ( argc ) { // terminate if command-line errors |
---|
25 | case 2, 3: |
---|
26 | open( in, argv[1] ); // open input file first as output creates file |
---|
27 | if ( argc == 3 ) open( out, argv[2] ); // do not create output unless input opens |
---|
28 | case 1: ; // use default files |
---|
29 | default: // wrong number of options |
---|
30 | exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]"; |
---|
31 | } // choose |
---|
32 | } catch( Open_Failure * ex ; ex->istream == &in ) { |
---|
33 | exit | "Unable to open input file" | argv[1]; |
---|
34 | } catch( Open_Failure * ex ; ex->ostream == &out ) { |
---|
35 | close( in ); // optional |
---|
36 | exit | "Unable to open output file" | argv[2]; |
---|
37 | } // try |
---|
38 | |
---|
39 | out | nlOff; // turn off auto newline |
---|
40 | in | nlOn; // turn on reading newline |
---|
41 | |
---|
42 | char ch; |
---|
43 | for () { // read all characters |
---|
44 | in | ch; |
---|
45 | if ( eof( in ) ) break; // eof ? |
---|
46 | out | ch; |
---|
47 | } // for |
---|
48 | } // main |
---|
49 | |
---|
50 | // Local Variables: // |
---|
51 | // tab-width: 4 // |
---|
52 | // compile-command: "cfa copyfile.cfa" // |
---|
53 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.