stringConcat

stringConcat - (In Java this loop takes forever string...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// stringConcat.cpp / // Show how C++ strings are mutable, by concatenating // characters to an existing string. Also, show that // C++'s implementation is more efficient than that of java. / // strings are mutable (thinly disguised array of bytes) / // by Mark Weiss / #include <iostream> #include <string> using namespace std; u // Return a string of length n filled with letter A's.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // (In Java, this loop takes forever. ..) string makeLongString( int n ) { string result = ""; s for( int i = 0; i < n; i++ ) result += "A"; r return result; } void stringConcat( ) { string bigString = makeLongString( 250000 ); s cout << "Length is " << bigString.length( ) << endl; c }...
View Full Document

This note was uploaded on 10/17/2010 for the course SCIS COP 4338 taught by Professor Kipirvine during the Spring '10 term at FIU.

Ask a homework question - tutors are online