diff options
author | bnewbold <bnewbold@robocracy.org> | 2010-03-25 06:29:54 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2010-03-25 06:29:54 -0400 |
commit | 0bf28391b00b1e28c44324bcd7647df416314667 (patch) | |
tree | 6dda90e70218861975deb408eb21b2ff00eb5ef6 /.vim/c-support/codesnippets/print_array.cc.noindent | |
parent | 564a2d0d39c8e1fb79ee800973848b2442833356 (diff) | |
download | openwrt-repro-0bf28391b00b1e28c44324bcd7647df416314667.tar.gz openwrt-repro-0bf28391b00b1e28c44324bcd7647df416314667.zip |
lots and lots of vim stuff for c development...
Diffstat (limited to '.vim/c-support/codesnippets/print_array.cc.noindent')
-rw-r--r-- | .vim/c-support/codesnippets/print_array.cc.noindent | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/.vim/c-support/codesnippets/print_array.cc.noindent b/.vim/c-support/codesnippets/print_array.cc.noindent new file mode 100644 index 0000000..52c43d3 --- /dev/null +++ b/.vim/c-support/codesnippets/print_array.cc.noindent @@ -0,0 +1,29 @@ + +// === FUNCTION ====================================================================== +// Name: print_array +// Description: Print an array with one dimension. +// Use +// print_array<T,w>( *matrix, n1*n2, n2, "matrix" ); +// for +// T matrix[n1][n2]; +// ===================================================================================== + template <class T, int width> +void print_array ( T *array, // array to print + int n, // number of elements to print + int nrow, // number of elements per row + string arrayname // array name + ) +{ + string line(" index | content\n ------+-"); + + cout << "\n\n array \"" << arrayname << "\", length " << n << endl << endl; + cout << line.append(width*nrow, '-'); + for ( int i=0; i<n; i+=1 ) { + if( i%nrow == 0 ) + cout << endl << setw(6) << i << " | "; + cout << "" << setw(width) << fixed << setprecision(2) << array[i]; + } + cout << endl << endl; + return ; +} // ---------- end of function print_double_array ---------- + |