Jump to content

Repeat a string: Difference between revisions

no edit summary
(Forth)
No edit summary
Line 37:
}
 
</lang>
 
=={{header|C++}}==
<lang C++>#include <string>
#include <iostream>
 
std::string repeat( std::string word, int times ) {
std::string to_append( word ) ;
for ( int a = 0 ; a < times - 1 ; a++ )
word.append( to_append ) ;
return word ;
}
 
int main( ) {
std::cout << repeat( "Ha" , 5 ) << std::endl ;
return 0 ;
}
</lang>
 
262

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.