source: translator/examples/vector_test.c @ 02e9ae2

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 02e9ae2 was 17cd4eb, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

fixed restrict, fixed parameter copy, introduced name table for types, changed variable after to string

  • Property mode set to 100644
File size: 906 bytes
Line 
1#include "fstream.h"
2#include "vector_int.h"
3#include "array.h"
4#include "iterator.h"
5
6int main() {
7    ofstream *sout = ofstream_stdout();
8    ifstream *sin = ifstream_stdin();
9    vector_int vec = vector_int_allocate();
10
11    // read in numbers until EOF or error
12    int num;
13
14    sout << "enter N elements and C-d on a separate line:\n";
15    for ( ;; ) {
16        sin >> &num;
17      if ( fail( sin ) || eof( sin ) ) break;
18        append( &vec, num );
19    }
20    // write out the numbers
21
22    sout << "Array elements:\n";
23//    write_all( begin( vec ), end( vec ), sout );
24//    sout << "\n";
25    for ( int index = 0; index <= last( vec ); index += 1 ) {
26        sout << vec[ index ] << " ";
27    }
28    sout << "\n";
29#if 1
30    sout << "Array elements reversed:\n";
31    write_reverse( begin( vec ), end( vec ), sout );
32    sout << "\n";
33#endif
34}
35
36// ../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.