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 c8ffe20b was 134b86a, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago |
|
add compiler flag to driver, update examples, fix unnamed bit fields
|
-
Property mode
set to
100644
|
|
File size:
976 bytes
|
| Rev | Line | |
|---|
| [51b73452] | 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"
|
|---|
| [134b86a] | 9 | #include "iterator.h"
|
|---|
| [51b73452] | 10 |
|
|---|
| [134b86a] | 11 | int 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 >> #
|
|---|
| 21 | if ( fail( sin ) || eof( sin ) ) break;
|
|---|
| 22 | append( &vec, num );
|
|---|
| 23 | }
|
|---|
| [51b73452] | 24 |
|
|---|
| [134b86a] | 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";
|
|---|
| [51b73452] | 37 | }
|
|---|
| [134b86a] | 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.