initial
This commit is contained in:
19
stringConcatenation.cpp
Normal file
19
stringConcatenation.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
// return a string that contains n As
|
||||
// In Java this code takes forever
|
||||
string makeLongString( int n )
|
||||
{
|
||||
string result = "";
|
||||
for( int i = 0; i < n; i++ )
|
||||
result += "A";
|
||||
return result;
|
||||
}
|
||||
int main( )
|
||||
{
|
||||
string manyAs = makeLongString( 250000 );
|
||||
cout << "Short string is " << makeLongString( 20 ) << endl;
|
||||
cout << "Length is " << manyAs.length( ) << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user