Changes in src/examples/iostream.c [86bd7c1f:e56cfdb0]
- File:
-
- 1 edited
-
src/examples/iostream.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/iostream.c
r86bd7c1f re56cfdb0 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 18:18:13201513 // Update Count : 212 // Last Modified On : Thu Nov 19 17:54:38 2015 13 // Update Count : 4 14 14 // 15 15 … … 30 30 forall( dtype ostype | ostream( ostype ) ) 31 31 ostype * ?<<?( ostype *os, int i ) { 32 char buffer[ 20];// larger than the largest integer32 char buffer[32]; // larger than the largest integer 33 33 sprintf( buffer, "%d", i ); 34 34 return write( os, buffer, strlen( buffer ) ); … … 37 37 forall( dtype ostype | ostream( ostype ) ) 38 38 ostype * ?<<?( ostype *os, double d ) { 39 char buffer[32]; // larger than the largest double39 char buffer[32]; // larger than the largest double 40 40 sprintf( buffer, "%g", d ); 41 41 return write( os, buffer, strlen( buffer ) ); … … 46 46 return write( os, cp, strlen( cp ) ); 47 47 } 48 49 forall( dtype ostype | ostream( ostype ) ) 50 ostype * ?<<?( ostype *os, const void *p ) { 51 char buffer[32]; // larger than the largest pointer 52 sprintf( buffer, "%p", p ); 53 return write( os, buffer, strlen( buffer ) ); 54 } 55 56 forall( type elt_type | writeable( elt_type ), 57 type iterator_type | iterator( iterator_type, elt_type ), 58 dtype os_type | ostream( os_type ) ) 59 void write( iterator_type begin, iterator_type end, os_type *os ) { 60 void print( elt_type i ) { 61 os << i << ' '; 62 } 63 for_each( begin, end, print ); 64 } 65 66 forall( type elt_type | writeable( elt_type ), 67 type iterator_type | iterator( iterator_type, elt_type ), 68 dtype os_type | ostream( os_type ) ) 69 void write_reverse( iterator_type begin, iterator_type end, os_type *os ) { 70 void print( elt_type i ) { 71 os << i << ' '; 72 } 73 for_each_reverse( begin, end, print ); 74 } 75 48 76 49 77 forall( dtype istype | istream( istype ) )
Note:
See TracChangeset
for help on using the changeset viewer.