// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // vector_test.c -- // // Author : Richard C. Bilson // Created On : Wed May 27 17:56:53 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Wed May 27 18:42:55 2015 // Update Count : 2 // #include "fstream.h" #include "vector_int.h" #include "array.h" #include "iterator.h" int main() { ofstream *sout = ofstream_stdout(); ifstream *sin = ifstream_stdin(); vector_int vec = vector_int_allocate(); // read in numbers until EOF or error int num; sout << "enter N elements and C-d on a separate line:\n"; for ( ;; ) { sin >> # if ( fail( sin ) || eof( sin ) ) break; append( &vec, num ); } // write out the numbers sout << "Array elements:\n"; // write_all( begin( vec ), end( vec ), sout ); // sout << "\n"; for ( int index = 0; index <= last( vec ); index += 1 ) { sout << vec[ index ] << " "; } sout << "\n"; #if 1 sout << "Array elements reversed:\n"; write_reverse( begin( vec ), end( vec ), sout ); sout << "\n"; #endif } // ../bin/cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o // Local Variables: // // tab-width: 4 // // compile-command: "cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o" // // End: //