File:  [Research Unix] / researchv10no / cmd / cfront / libstring / test1.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

// String test program.

#include "String.h"

String
doubleCat(String a, String b)
{
	a.put(b);
	return a + a;
}

String
substr ( String x, int start, int length )
{
	return x(start, length);
}

main(int argc, char **argv)
{
	String	s = "Hello, ";
	cout << doubleCat ( s, "world.\n" );
	while ( argc-- ) {
		String	x(*argv++);
		for ( int i = 0; i <= length(x); i++ ) {
			cout << substr(x, 0, i) << "\t" <<
			    substr(x, i, length(x) - i) << "\t";
			// split the expression to be kind to ccom
			cout << substr(x, 0, length(x) - i) << "\t" <<
			    x(length(x) - i, i) <<  "\n";
		}
		cout << "\n";
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.