source:
src/examples/vector_test.c@
6ed1d4b
| Last change on this file since 6ed1d4b was d3b7937, checked in by , 10 years ago | |
|---|---|
|
|
| File size: 1.2 KB | |
| Rev | Line | |
|---|---|---|
| [86bd7c1f] | 1 | // |
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | |
| 3 | // | |
| 4 | // The contents of this file are covered under the licence agreement in the | |
| 5 | // file "LICENCE" distributed with Cforall. | |
| 6 | // | |
| 7 | // vector_test.c -- | |
| 8 | // | |
| 9 | // Author : Richard C. Bilson | |
| 10 | // Created On : Wed May 27 17:56:53 2015 | |
| 11 | // Last Modified By : Peter A. Buhr | |
| [d3b7937] | 12 | // Last Modified On : Tue Jan 26 17:14:52 2016 |
| 13 | // Update Count : 17 | |
| [86bd7c1f] | 14 | // |
| 15 | ||
| [d3b7937] | 16 | #include <fstream> |
| 17 | #include <iterator> | |
| [51b73452] | 18 | #include "vector_int.h" |
| 19 | #include "array.h" | |
| 20 | ||
| [784deab] | 21 | int main( void ) { |
| [86bd7c1f] | 22 | ofstream *sout = ofstream_stdout(); |
| 23 | ifstream *sin = ifstream_stdin(); | |
| 24 | vector_int vec = vector_int_allocate(); | |
| [134b86a] | 25 | |
| [86bd7c1f] | 26 | // read in numbers until EOF or error |
| 27 | int num; | |
| [134b86a] | 28 | |
| [cf16f94] | 29 | sout | "enter N elements and C-d on a separate line:" | endl; |
| [86bd7c1f] | 30 | for ( ;; ) { |
| [cf16f94] | 31 | sin | # |
| [86bd7c1f] | 32 | if ( fail( sin ) || eof( sin ) ) break; |
| [e56cfdb0] | 33 | append( &vec, num ); |
| [86bd7c1f] | 34 | } |
| 35 | // write out the numbers | |
| [134b86a] | 36 | |
| [cf16f94] | 37 | sout | "Array elements:" | endl; |
| [e56cfdb0] | 38 | write( begin( vec ), end( vec ), sout ); |
| [cf16f94] | 39 | sout | endl; |
| [e56cfdb0] | 40 | |
| [cf16f94] | 41 | sout | "Array elements reversed:" | endl; |
| [86bd7c1f] | 42 | write_reverse( begin( vec ), end( vec ), sout ); |
| [cf16f94] | 43 | sout | endl; |
| [51b73452] | 44 | } |
| [134b86a] | 45 | |
| [86bd7c1f] | 46 | // Local Variables: // |
| 47 | // tab-width: 4 // | |
| [d3b7937] | 48 | // compile-command: "cfa vector_test.c vector_int.o array.o" // |
| [86bd7c1f] | 49 | // End: // |
Note:
See TracBrowser
for help on using the repository browser.