source: src/examples/vector_test.c@ 7754cde

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 7754cde was cf16f94, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

create temporary return variable for return expressions, remove unnecessary code after temporary-return-variable change, fix missing lvalue qualifiers, change stream operator to |

  • Property mode set to 100644
File size: 1.2 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 : Peter A. Buhr
12// Last Modified On : Tue Dec 15 16:02:56 2015
13// Update Count : 13
14//
15
16#include "fstream.h"
17#include "vector_int.h"
18#include "array.h"
19#include "iterator.h"
20
21int main() {
22 ofstream *sout = ofstream_stdout();
23 ifstream *sin = ifstream_stdin();
24 vector_int vec = vector_int_allocate();
25
26 // read in numbers until EOF or error
27 int num;
28
29 sout | "enter N elements and C-d on a separate line:" | endl;
30 for ( ;; ) {
31 sin | &num;
32 if ( fail( sin ) || eof( sin ) ) break;
33 append( &vec, num );
34 }
35 // write out the numbers
36
37 sout | "Array elements:" | endl;
38 write( begin( vec ), end( vec ), sout );
39 sout | endl;
40
41 sout | "Array elements reversed:" | endl;
42 write_reverse( begin( vec ), end( vec ), sout );
43 sout | endl;
44}
45
46// Local Variables: //
47// tab-width: 4 //
48// compile-command: "cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o" //
49// End: //
Note: See TracBrowser for help on using the repository browser.