source: tests/.in/copyfile.txt @ 8d321f9

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 8d321f9 was 3d46f01, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

change from pointers to references in tests/copyfile.cfa

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[8d75345a]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       : Tue Jul 16 16:47:22 2019
11// Last Modified By : Peter A. Buhr
[3d46f01]12// Last Modified On : Mon Jun  1 09:10:58 2020
13// Update Count     : 28
[8d75345a]14//
15
16#include <fstream.hfa>
[3f654ec]17#include <stdlib.hfa>                                                                   // new/delete
[8d75345a]18
19int main( int argc, char * argv[] ) {
[3d46f01]20        ifstream & in  = stdin;                                                         // default files
21        ofstream & out = stdout;
[3f654ec]22        try {
23                choose ( argc ) {
24                  case 2, 3:
[3d46f01]25                          &in = new( (const char *)argv[1] );           // open input file first as output creates file
26                          if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent
[3f654ec]27                  case 1: ;                                     // use default files
28                  default:
29                          exit | "Usage [ input-file (default stdin) [ output-file (default stdout) ] ]";
30                } // choose
[8d75345a]31
[3f654ec]32                char ch;
[3d46f01]33                out | nlOff;                                                                    // turn off auto newline
34                in  | nlOn;                                                                             // turn on reading newline
[8d75345a]35
[3f654ec]36                for () {                                                                                // read all characters
[3d46f01]37                        in | ch;
38                  if ( eof( in ) ) break;                                               // eof ?
39                        out | ch;
[3f654ec]40                } // for
41        } finally {
[3d46f01]42                if ( &in  != &stdin  ) delete( &in );                   // close file, do not delete stdin!
43                if ( &out != &stdout ) delete( &out );                  // close file, do not delete stdout!
[3f654ec]44        } // try
[8d75345a]45} // main
46
47// Local Variables: //
48// tab-width: 4 //
49// compile-command: "cfa copyfile.cfa" //
50// End: //
Note: See TracBrowser for help on using the repository browser.