|
|
1.1 ! root 1: // String test program. ! 2: ! 3: #include "String.h" ! 4: ! 5: String ! 6: doubleCat(String a, String b) ! 7: { ! 8: a.put(b); ! 9: return a + a; ! 10: } ! 11: ! 12: String ! 13: substr ( String x, int start, int length ) ! 14: { ! 15: return x(start, length); ! 16: } ! 17: ! 18: main(int argc, char **argv) ! 19: { ! 20: String s = "Hello, "; ! 21: cout << doubleCat ( s, "world.\n" ); ! 22: while ( argc-- ) { ! 23: String x(*argv++); ! 24: for ( int i = 0; i <= length(x); i++ ) { ! 25: cout << substr(x, 0, i) << "\t" << ! 26: substr(x, i, length(x) - i) << "\t"; ! 27: // split the expression to be kind to ccom ! 28: cout << substr(x, 0, length(x) - i) << "\t" << ! 29: x(length(x) - i, i) << "\n"; ! 30: } ! 31: cout << "\n"; ! 32: } ! 33: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.