source: translator/examples/vector_test.c @ d9a0e76

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 d9a0e76 was d11f789, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

roll back remove and reorder hoisted aggregate, format adjustment

  • Property mode set to 100644
File size: 863 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#if 0
26    write_reverse( begin( vec ), end( vec ), sout );
27    sout << "\n";
28
29#endif
30    for ( int index = 0; index <= last( vec ); index += 1 ) {
31        sout << vec[ index ] << " ";
32    }
33    sout << "\n";
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.