source: src/examples/vector_test.c @ d9f1b2d

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d9f1b2d was 1ad1c99e, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

modified vector_test to use constructors and destructors

  • Property mode set to 100644
File size: 1.1 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// vector_test.c --
8//
9// Author           : Richard C. Bilson
10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Rob Schluntz
12// Last Modified On : Wed Apr 27 17:31:27 2016
13// Update Count     : 18
14//
15
16#include <fstream>
17#include <iterator>
18#include "vector_int.h"
19#include "array.h"
20
21int main( void ) {
22        vector_int vec;
23
24        // read in numbers until EOF or error
25        int num;
26
27        sout | "enter N elements and C-d on a separate line:" | endl;
28        for ( ;; ) {
29                sin | &num;
30          if ( fail( sin ) || eof( sin ) ) break;
31                append( &vec, num );
32        }
33        // write out the numbers
34
35        sout | "Array elements:" | endl;
36        write( begin( &vec ), end( &vec ), sout );
37        sout | endl;
38
39        sout | "Array elements reversed:" | endl;
40        write_reverse( begin( &vec ), end( &vec ), sout );
41        sout | endl;
42}
43
44// Local Variables: //
45// tab-width: 4 //
46// compile-command: "cfa vector_test.c vector_int.o array.o" //
47// End: //
Note: See TracBrowser for help on using the repository browser.