Changes in src/examples/vector_test.c [86bd7c1f:843054c2]
- File:
-
- 1 edited
-
src/examples/vector_test.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/vector_test.c
r86bd7c1f r843054c2 1 //2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // vector_test.c --8 //9 // Author : Richard C. Bilson10 // Created On : Wed May 27 17:56:53 201511 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed May 27 18:42:55 201513 // Update Count : 214 //15 16 1 #include "fstream.h" 17 2 #include "vector_int.h" … … 20 5 21 6 int main() { 22 ofstream *sout = ofstream_stdout();23 ifstream *sin = ifstream_stdin();24 vector_int vec = vector_int_allocate();7 ofstream *sout = ofstream_stdout(); 8 ifstream *sin = ifstream_stdin(); 9 vector_int vec = vector_int_allocate(); 25 10 26 // read in numbers until EOF or error27 int num;11 // read in numbers until EOF or error 12 int num; 28 13 29 sout << "enter N elements and C-d on a separate line:\n";30 for ( ;; ) {14 sout << "enter N elements and C-d on a separate line:\n"; 15 for ( ;; ) { 31 16 sin >> # 32 if ( fail( sin ) || eof( sin ) ) break;17 if ( fail( sin ) || eof( sin ) ) break; 33 18 append( &vec, num ); 34 }35 // write out the numbers19 } 20 // write out the numbers 36 21 37 sout << "Array elements:\n";38 // write_all( begin( vec ), end( vec ), sout );39 // sout << "\n";40 for ( int index = 0; index <= last( vec ); index += 1 ) {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 ) { 41 26 sout << vec[ index ] << " "; 42 }43 sout << "\n";27 } 28 sout << "\n"; 44 29 #if 1 45 sout << "Array elements reversed:\n";46 write_reverse( begin( vec ), end( vec ), sout );47 sout << "\n";30 sout << "Array elements reversed:\n"; 31 write_reverse( begin( vec ), end( vec ), sout ); 32 sout << "\n"; 48 33 #endif 49 34 } 50 35 51 36 // ../bin/cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o 52 53 // Local Variables: //54 // tab-width: 4 //55 // compile-command: "cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o" //56 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.