Changeset 784deab for src/examples
- Timestamp:
- Jan 8, 2016, 10:37:10 PM (8 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
- Location:
- src/examples
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/alloc.c
r1cced28 r784deab 26 26 int *baz( int *p, int c ); 27 27 28 int main( ) {28 int main( void ) { 29 29 size_t size = 10; 30 30 int * x = malloc(); -
src/examples/control_structures.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 : Fri Sep 18 08:12:17 201513 // Update Count : 2 812 // Last Modified On : Mon Jan 4 11:30:30 2016 13 // Update Count : 29 14 14 // 15 15 16 int main( ) {16 int main( void ) { 17 17 L1: { 18 18 L2: switch ( 3_333_333 ) { // underscores in constant -
src/examples/fstream_test.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 Nov 23 14:43:32 201513 // Update Count : 4 012 // Last Modified On : Mon Jan 4 11:30:39 2016 13 // Update Count : 41 14 14 // 15 15 16 16 #include "fstream.h" 17 17 18 int main( ) {18 int main( void ) { 19 19 ofstream *sout = ofstream_stdout(); 20 20 ifstream *sin = ifstream_stdin(); -
src/examples/identity.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 : Wed May 27 18:16:30 201513 // Update Count : 212 // Last Modified On : Mon Jan 4 23:38:05 2016 13 // Update Count : 6 14 14 // 15 15 … … 23 23 int main() { 24 24 ofstream *sout = ofstream_stdout(); 25 char c = 'a'; 26 c = identity( c ); 27 sout << c << ' ' << identity( c ) << '\n'; 28 int i = 5; 29 i = identity( i ); 30 sout << i << ' ' << identity( i ) << '\n'; 31 double d = 3.2; 32 d = identity( d ); 33 sout << d << ' ' << identity( d ) << '\n'; 25 sout | "char\t\t\t" | identity( 'z' ) | endl; 26 sout | "signed int\t\t" | identity( 4 ) | endl; 27 sout | "unsigned int\t\t" | identity( 4u ) | endl; 28 sout | "signed long int\t\t" | identity( 4l ) | endl; 29 sout | "unsigned long int\t" | identity( 4ul ) | endl; 30 sout | "signed long long int\t" | identity( 4ll ) | endl; 31 sout | "unsigned long long int\t" | identity( 4ull ) | endl; 32 sout | "float\t\t\t" | identity( 4.0f ) | endl; 33 sout | "double\t\t\t" | identity( 4.0 ) | endl; 34 sout | "long double\t\t" | identity( 4.0l ) | endl; 34 35 } 35 36 36 37 // Local Variables: // 37 38 // tab-width: 4 // 38 // compile-command: "cfa identity.c fstream.o iostream.o " //39 // compile-command: "cfa identity.c fstream.o iostream.o iterator.o" // 39 40 // End: // -
src/examples/includes.c
r1cced28 r784deab 7 7 // includes.c -- 8 8 // 9 // Author : Richard C. Bilson9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 26 15:04:33201513 // Update Count : 1412 // Last Modified On : Mon Dec 21 13:54:09 2015 13 // Update Count : 322 14 14 // 15 15 16 #if 0 17 //#include <aio.h> // FAILS -- includes locale.h 16 // *********************************************** 17 // USE -std=c99 WITH gxx TO GET SAME OUTPUT AS cfa 18 // *********************************************** 19 20 #ifdef __CFA__ 21 extern "C" { 22 #endif // __CFA__ 23 24 #if 1 25 #define _GNU_SOURCE 26 #include <aio.h> 27 #include <a.out.h> 18 28 #include <aliases.h> 19 29 #include <alloca.h> 20 30 #include <ansidecl.h> 21 31 #include <ar.h> 22 #include <argp.h> // FAILS -- includes locale.h23 #include <argz.h> // FAILS -- includes locale.h32 #include <argp.h> 33 #include <argz.h> 24 34 #include <assert.h> 25 #include <bfd.h> // contains structure field "type" 35 #include <bfd.h> 36 #include <bfdlink.h> 37 #include <byteswap.h> 38 #include <cblas.h> 39 #include <cblas_f77.h> 26 40 #include <complex.h> 27 #include <ctype.h> // FAILS -- includes locale.h 41 #include <cpio.h> 42 #include <crypt.h> 43 #include <ctype.h> 44 #include <curses.h> 45 #include <demangle.h> // enum / contains "type" 46 #include <dialog.h> // enum / contains "type" 47 #include <dirent.h> 48 #include <dis-asm.h> 49 #include <dlfcn.h> 50 #include <dlg_colors.h> 51 #include <dlg_config.h> 52 #include <dlg_keys.h> 53 #include <elf.h> 54 #include <endian.h> 55 #include <envz.h> 56 #include <err.h> 28 57 #include <errno.h> 58 #include <error.h> 59 #if 0 60 #include <eti.h> 61 #include <evdns.h> // subdirectory event2 contains "type" 62 #include <event.h> 63 #include <evhttp.h> // enum / subdirectory event2 contains "type" 64 #include <evrpc.h> 65 #include <evutil.h> 66 #include <execinfo.h> 67 #include <expat.h> // enum / contains "type" and "context" 68 #include <expat_config.h> 69 #include <expat_external.h> 70 #include <fcntl.h> 71 #include <features.h> 29 72 #include <fenv.h> 30 73 #include <float.h> 74 #include <fmtmsg.h> 75 #include <fnmatch.h> 76 #include <form.h> // contains "type" 77 #include <fpu_control.h> 78 #include <fstab.h> 79 //#include <ft2build.h> 80 #include <fts.h> 81 #include <ftw.h> 82 #include <gconv.h> 83 //#include <gcrypt.h> // enum / contains "type" 84 //#include <gcrypt-module.h> 85 #include <getopt.h> 86 //#include <gettext-po.h> 87 #include <glob.h> 88 //#include <gmp.h> // infinite loop 89 ////#include <gmpxx.h> 90 //#include <gmp-x86_64.h> 91 #include <gnu-versions.h> 92 //#include <gpg-error.h> 93 #include <grp.h> 94 #include <gshadow.h> 95 #include <iconv.h> 96 #include <idna.h> 97 #include <idn-free.h> 98 #include <idn-int.h> 99 #include <ieee754.h> 100 #include <ifaddrs.h> 31 101 #include <inttypes.h> 32 102 #include <iso646.h> 103 #include <jerror.h> 104 //#include <jmorecfg.h> 105 //#include <jpegint.h> 106 //#include <jpeglib.h> 33 107 #include <limits.h> 34 #include <locale.h> // FAILS -- "no reasonable alternatives for applying ... Name: ?+? ..." 35 #include <math.h> // contains structure field "type" 108 #include <locale.h> 109 #include <math.h> // contains "type" 110 #include <ncurses.h> 36 111 #include <setjmp.h> 37 112 #include <signal.h> … … 41 116 #include <stdlib.h> 42 117 #include <stdio.h> 43 #include <string.h> // FAILS -- includes locale.h118 #include <string.h> 44 119 #include <tgmath.h> 45 #include <time.h> // FAILS -- includes locale.h120 #include <time.h> 46 121 #include <unistd.h> 47 #include <wchar.h> // FAILS -- includes locale.h 48 #include <wctype.h> // FAILS -- includes locale.h 49 #include <curses.h> 122 #include <wchar.h> 123 #include <wctype.h> 124 #endif // 0 125 50 126 #else 51 #include <aio.h> // FAILS -- includes locale.h 127 128 //#define _GNU_SOURCE 129 #include <error.h> 130 52 131 #endif // 0 132 133 #ifdef __CFA__ 134 } // extern "C" 135 #endif // __CFA__ 53 136 54 137 // Local Variables: // -
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 -
src/examples/iostream.h
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 Nov 23 14:15:25 201513 // Update Count : 1712 // Last Modified On : Mon Jan 4 09:02:11 2016 13 // Update Count : 20 14 14 // 15 15 … … 34 34 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, char ); 35 35 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, int ); 36 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned int ); 37 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long int ); 38 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long long int ); 39 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long int ); 40 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long long int ); 36 41 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double ); 42 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double ); 37 43 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * ); 38 44 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * ); -
src/examples/min.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 : Wed May 27 18:23:19 201513 // Update Count : 2 12 // Last Modified On : Mon Jan 4 11:40:51 2016 13 // Update Count : 26 14 14 // 15 15 16 extern "C" { 17 int printf( const char *, ... ); 18 //#include <stdio.h> 19 } 16 #include "fstream.h" 20 17 21 18 forall( type T | { int ?<?( T, T ); } ) 22 19 T min( const T t1, const T t2 ) { 23 20 return t1 < t2 ? t1 : t2; 24 } 21 } // min 25 22 26 int main() { 27 char c; 28 // c = min( 'z', 'a' ); 29 // printf( "minimum %d\n", c ); 30 int i; 31 i = min( 4, 3 ); 32 printf( "minimum %d\n", min( 4, 3 ) ); 33 float f; 34 f = min( 4.0, 3.1 ); 35 printf( "minimum %g\n", f ); 36 double d; 37 d = min( 4.0, 3.2 ); 38 printf( "minimum %g\n", d ); 39 } 23 int main( void ) { 24 ofstream *sout = ofstream_stdout(); 25 // char does not have less than. 26 int ?<?( char op1, char op2 ) { return (int)op1 < (int)op2; } 27 28 sout | "char\t\t\t" | 'z' | ' ' | 'a' | "\tmin " | min( 'z', 'a' ) | endl; 29 sout | "signed int\t\t" | 4 | ' ' | 3 | "\tmin " | min( 4, 3 ) | endl; 30 sout | "unsigned int\t\t" | 4u | ' ' | 3u | "\tmin " | min( 4u, 3u ) | endl; 31 sout | "signed long int\t\t" | 4l | ' ' | 3l | "\tmin " | min( 4l, 3l ) | endl; 32 sout | "unsigned long int\t" | 4ul | ' ' | 3ul | "\tmin " | min( 4ul, 3ul ) | endl; 33 sout | "signed long long int\t" | 4ll | ' ' | 3ll | "\tmin " | min( 4ll, 3ll ) | endl; 34 sout | "unsigned long long int\t" | 4ull | ' ' | 3ull | "\tmin " | min( 4ull, 3ull ) | endl; 35 sout | "float\t\t\t" | 4.0f | ' ' | 3.1f | "\tmin " | min( 4.0f, 3.1f ) | endl; 36 sout | "double\t\t\t" | 4.0 | ' ' | 3.1 | "\tmin " | min( 4.0, 3.1 ) | endl; 37 sout | "long double\t\t" | 4.0l | ' ' | 3.1l | "\tmin " | min( 4.0l, 3.1l ) | endl; 38 } // main 40 39 41 40 // Local Variables: // 42 41 // tab-width: 4 // 43 // compile-command: "cfa min.c " //42 // compile-command: "cfa min.c fstream.o iostream.o iterator.o" // 44 43 // End: // -
src/examples/quoted_keyword.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 : Wed May 27 18:27:26 201513 // Update Count : 212 // Last Modified On : Sun Jan 3 22:46:28 2016 13 // Update Count : 7 14 14 // 15 15 16 #include "fstream.h" 17 16 18 // test quoted keyword usage 17 int `catch` ;19 int `catch` = 10; 18 20 19 21 struct { 20 22 int `type`; 21 23 int `struct`; 22 } st ;24 } st = { 10, 10 }; 23 25 24 26 typedef int `forall`; 25 `forall` `throw` ;27 `forall` `throw` = 10; 26 28 27 int foo() { 28 int w = `catch` + st.`type` + st.`struct` + `throw`; 29 int main() { 30 ofstream *sout = ofstream_stdout(); 31 sout | `catch` + st.`type` + st.`struct` + `throw` | endl; 29 32 } 30 33 -
src/examples/s.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 : Wed May 27 18:42:39 201513 // Update Count : 212 // Last Modified On : Sun Jan 3 22:38:45 2016 13 // Update Count : 3 14 14 // 15 15 … … 17 17 18 18 void f() { 19 //int a;20 //a ? 4 : 5;19 int a; 20 a ? 4 : 5; 21 21 1 ? 4 : 5; 22 22 0 ? 4 : 5; -
src/examples/square.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 : Wed May 27 18:43:34 201513 // Update Count : 2 12 // Last Modified On : Tue Jan 5 18:08:20 2016 13 // Update Count : 21 14 14 // 15 15 16 extern "C" { 17 #include <stdio.h> 18 } 16 #include "fstream.h" 19 17 20 18 forall( type T | { T ?*?( T, T ); } ) 21 19 T square( T t ) { 22 20 return t * t; 23 } 24 25 //char ?*?( char a1, char a2 ) { 26 // return (char)( (int)a1 * (int)a2 ); 27 //} 21 } // square 28 22 29 23 int main() { 30 char c = 5; 31 short int s = 5; 32 int i = 5; 33 float f = 5.0; 34 double d = 5.0; 35 // printf( "result of square of 5 is %d\n", (char)square( c ) ); 36 printf( "result of square of 5 is %d\n", square( s ) ); 37 printf( "result of square of 5 is %d\n", square( i ) ); 38 printf( "result of square of 5 is %f\n", square( f ) ); 39 printf( "result of square of 5 is %f\n", square( d ) ); 40 } 24 #if 0 25 ofstream *sout = ofstream_stdout(); 26 sout | "result of squaring 9 is " | endl; 27 28 // char does not have multiplication. 29 char ?*?( char a1, char a2 ) { 30 return (char)((int)a1 * (int)a2); 31 } // ?*? 32 char c = 9; 33 sout | "char\t\t\t" | square( c ) | endl; 34 35 sout | square( s ) | endl; 36 #endif 37 short int s = 9; 38 square( s ); 39 #if 0 40 signed int i = 9; 41 sout | "signed int\t\t" | square( i ) | endl; 42 43 unsigned int ui = 9; 44 sout | "unsigned int\t\t" | square( ui ) | endl; 45 46 long int li = 9; 47 sout | "signed long int\t\t" | square( li ) | endl; 48 49 unsigned long int uli = 9; 50 sout | "unsigned long int\t" | square( uli ) | endl; 51 52 signed long long int lli = 9; 53 sout | "signed long long int\t" | square( lli ) | endl; 54 55 unsigned long long int ulli = 9; 56 sout | "unsigned long long int\t" | square( ulli ) | endl; 57 58 float f = 9.0; 59 sout | "float\t\t\t" | square( f ) | endl; 60 61 double d = 9.0; 62 sout | "double\t\t\t" | square( d ) | endl; 63 64 long double ld = 9.0; 65 sout | "long double\t\t" | square( ld ) | endl; 66 #endif 67 } // main 41 68 42 69 // Local Variables: // 43 70 // tab-width: 4 // 44 // compile-command: "cfa square.c " //71 // compile-command: "cfa square.c fstream.o iostream.o iterator.o" // 45 72 // End: // -
src/examples/sum.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 : Sat Nov 21 18:08:18 201513 // Update Count : 1 1912 // Last Modified On : Mon Jan 4 07:40:24 2016 13 // Update Count : 126 14 14 // 15 15 16 extern "C" {17 int printf( char *, ... );18 }19 16 #include "fstream.h" 20 17 … … 41 38 char ?++( char *op ) { char temp = *op; *op += 1; return temp; } 42 39 43 int main( ) {40 int main( void ) { 44 41 const int low = 5, High = 15, size = High - low; 45 42 … … 52 49 a[i] = v; 53 50 } 54 sout << "sum from " << low << " to " << High <<" is "55 << (int)sum( size, a ) << ", check " << (int)s <<endl;51 sout | "sum from " | low | " to " | High | " is " 52 | (int)sum( size, a ) | ", check " | (int)s | endl; 56 53 57 54 int s = 0, a[size]; … … 61 58 a[i] = (int)v; 62 59 } 63 sout << "sum from " << low << " to " << High <<" is "64 << sum( size, (int *)a ) << ", check " << (int)s <<endl;60 sout | "sum from " | low | " to " | High | " is " 61 | sum( size, (int *)a ) | ", check " | (int)s | endl; 65 62 66 63 double s = 0.0, a[size]; … … 70 67 a[i] = (double)v; 71 68 } 72 printf( "%g\n", sum( size, (double *)a ) ); 73 // sout << "sum from " << low / 10.0 << " to " << High / 10.0 << " is " 74 // << sum( size, (double *)a ) << ", check " << (double)s << endl; 69 sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is " 70 | sum( size, (double *)a ) | ", check " | (double)s | endl; 75 71 76 72 float s = 0.0, a[size]; … … 80 76 a[i] = (float)v; 81 77 } 82 printf( "%g\n", sum( size, (float *)a ) ); 83 // sout << "sum from " << low / 10.0 << " to " << High / 10.0 << " is " 84 // << sum( size, (float *)a ) << ", check " << (float)s << endl; 78 sout | "sum from " | low / 10.0 | " to " | High / 10.0 | " is " 79 | sum( size, (float *)a ) | ", check " | (float)s | endl; 85 80 } 86 81 87 82 // Local Variables: // 88 83 // tab-width: 4 // 89 // compile-command: "cfa sum.c fstream.o iostream.o " //84 // compile-command: "cfa sum.c fstream.o iostream.o iterator.o" // 90 85 // End: // -
src/examples/swap.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 : Wed May 27 18:34:47 201513 // Update Count : 112 // Last Modified On : Mon Jan 4 11:32:25 2016 13 // Update Count : 5 14 14 // 15 15 16 extern "C" { 17 int printf( const char *, ... ); 18 } 16 #include "fstream.h" 19 17 20 18 forall( type T ) … … 25 23 } 26 24 27 int main( ) {25 int main( void ) { 28 26 int x = 1, y = 2; 29 printf( "%d %d\n", x, y ); 27 ofstream *sout = ofstream_stdout(); 28 sout | x | ' ' | y | endl; 30 29 swap( &x, &y ); 31 printf( "%d %d\n", x, y );30 sout | x | ' ' | y | endl; 32 31 } 33 32 34 33 // Local Variables: // 35 34 // tab-width: 4 // 36 // compile-command: "cfa swap.c " //35 // compile-command: "cfa swap.c fstream.o iostream.o iterator.o" // 37 36 // End: // -
src/examples/twice.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 : Wed May 27 18:37:23 201513 // Update Count : 1 12 // Last Modified On : Mon Jan 4 11:32:04 2016 13 // Update Count : 10 14 14 // 15 15 … … 21 21 } 22 22 23 int main() { 23 int main( void ) { 24 // char does not have addition 25 char ?+?( char op1, char op2 ) { return (int)op1 + op2; } // cast forces integer addition or recursion 26 char ++?( char *op ) { *op += 1; return *op; } 27 char ?++( char *op ) { char temp = *op; *op += 1; return temp; } 28 24 29 ofstream *sout = ofstream_stdout(); 25 sout << twice( 1 ) << ' ' << twice( 3.2 ) << '\n';30 sout | twice( 'a' ) | ' ' | twice( 1 ) | ' ' | twice( 3.2 ) | endl; 26 31 } 27 32 28 33 // Local Variables: // 29 34 // tab-width: 4 // 30 // compile-command: "cfa twice.c fstream.o iostream.o " //35 // compile-command: "cfa twice.c fstream.o iostream.o iterator.o" // 31 36 // End: // -
src/examples/vector_test.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 : Tue Dec 15 16:02:56 201513 // Update Count : 1 312 // Last Modified On : Mon Jan 4 11:31:56 2016 13 // Update Count : 14 14 14 // 15 15 … … 19 19 #include "iterator.h" 20 20 21 int main( ) {21 int main( void ) { 22 22 ofstream *sout = ofstream_stdout(); 23 23 ifstream *sin = ifstream_stdin();
Note: See TracChangeset
for help on using the changeset viewer.