// // 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 : Mon Jan 4 11:31:56 2016 // Update Count : 14 // #include "fstream.h" #include "vector_int.h" #include "array.h" #include "iterator.h" int main( void ) { 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:" | endl; for ( ;; ) { sin | # if ( fail( sin ) || eof( sin ) ) break; append( &vec, num ); } // write out the numbers sout | "Array elements:" | endl; write( begin( vec ), end( vec ), sout ); sout | endl; sout | "Array elements reversed:" | endl; write_reverse( begin( vec ), end( vec ), sout ); sout | endl; } // Local Variables: // // tab-width: 4 // // compile-command: "cfa vector_test.c fstream.o iostream.o vector_int.o iterator.o array.o" // // End: //