source: translator/examples/vector_test.c @ 8c17ab0

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 8c17ab0 was 134b86a, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

add compiler flag to driver, update examples, fix unnamed bit fields

  • Property mode set to 100644
File size: 976 bytes
Line 
1// "cfa -c -o vector_test.o vector_test.c"
2// "cfa -CFA vector_test.c > vector_test_out.c"
3// "cfa -E vector_test.c > vector_test_out.c"
4// "gcc31 -c vector_test_out.c -o vector_test.o"
5
6#include "fstream.h"
7#include "vector_int.h"
8#include "array.h"
9#include "iterator.h"
10
11int main() {
12    ofstream *sout = ofstream_stdout();
13    ifstream *sin = ifstream_stdin();
14    vector_int vec = vector_int_allocate();
15
16    // read in numbers until EOF or error
17    int num;
18
19    for ( ;; ) {
20        sin >> &num;
21      if ( fail( sin ) || eof( sin ) ) break;
22        append( &vec, num );
23    }
24
25    // write out the numbers
26
27    sout << "Array elements:\n";
28//    write_all( begin( vec ), end( vec ), sout );
29    sout << "\n";
30    write_reverse( begin( vec ), end( vec ), sout );
31    sout << "\n";
32
33    for ( int index = 0; index <= last( vec ); index += 1 ) {
34        sout << vec[ index ] << " ";
35    }
36    sout << "\n";
37}
38
39// ../bin/cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o
Note: See TracBrowser for help on using the repository browser.