Changeset 784deab for src/examples/iostream.c
- Timestamp:
- Jan 8, 2016, 10:37:10 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 61f9356
- Parents:
- 1cced28
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/iostream.c
r1cced28 r784deab 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 7 23:08:02 201513 // Update Count : 2412 // Last Modified On : Mon Jan 4 09:38:58 2016 13 // Update Count : 37 14 14 // 15 15 … … 27 27 forall( dtype ostype | ostream( ostype ) ) 28 28 ostype * ?|?( ostype *os, int i ) { 29 char buffer[32]; // larger than the largest integer 30 sprintf( buffer, "%d", i ); 31 return write( os, buffer, strlen( buffer ) ); 29 char buffer[32]; 30 return write( os, buffer, sprintf( buffer, "%d", i ) ); 31 } // ?|? 32 33 forall( dtype ostype | ostream( ostype ) ) 34 ostype * ?|?( ostype *os, unsigned int i ) { 35 char buffer[32]; 36 return write( os, buffer, sprintf( buffer, "%u", i ) ); 37 } // ?|? 38 39 forall( dtype ostype | ostream( ostype ) ) 40 ostype * ?|?( ostype *os, long int i ) { 41 char buffer[32]; 42 return write( os, buffer, sprintf( buffer, "%ld", i ) ); 43 } // ?|? 44 45 forall( dtype ostype | ostream( ostype ) ) 46 ostype * ?|?( ostype *os, long long int i ) { 47 char buffer[32]; 48 return write( os, buffer, sprintf( buffer, "%lld", i ) ); 49 } // ?|? 50 51 forall( dtype ostype | ostream( ostype ) ) 52 ostype * ?|?( ostype *os, unsigned long int i ) { 53 char buffer[32]; 54 return write( os, buffer, sprintf( buffer, "%lu", i ) ); 55 } // ?|? 56 57 forall( dtype ostype | ostream( ostype ) ) 58 ostype * ?|?( ostype *os, unsigned long long int i ) { 59 char buffer[32]; 60 return write( os, buffer, sprintf( buffer, "%llu", i ) ); 32 61 } // ?|? 33 62 34 63 forall( dtype ostype | ostream( ostype ) ) 35 64 ostype * ?|?( ostype *os, double d ) { 36 char buffer[32]; // larger than the largest double 37 sprintf( buffer, "%g", d ); 38 return write( os, buffer, strlen( buffer ) ); 65 char buffer[32]; 66 return write( os, buffer, sprintf( buffer, "%g", d ) ); 67 } // ?|? 68 69 forall( dtype ostype | ostream( ostype ) ) 70 ostype * ?|?( ostype *os, long double d ) { 71 char buffer[32]; 72 return write( os, buffer, sprintf( buffer, "%Lg", d ) ); 73 } // ?|? 74 75 forall( dtype ostype | ostream( ostype ) ) 76 ostype * ?|?( ostype *os, const void *p ) { 77 char buffer[32]; 78 return write( os, buffer, sprintf( buffer, "%p", p ) ); 39 79 } // ?|? 40 80 … … 42 82 ostype * ?|?( ostype *os, const char *cp ) { 43 83 return write( os, cp, strlen( cp ) ); 44 } // ?|?45 46 forall( dtype ostype | ostream( ostype ) )47 ostype * ?|?( ostype *os, const void *p ) {48 char buffer[32]; // larger than the largest pointer49 sprintf( buffer, "%p", p );50 return write( os, buffer, strlen( buffer ) );51 84 } // ?|? 52 85
Note: See TracChangeset
for help on using the changeset viewer.