C ++ program to concatenate a string given number of times | C ++ program to concatenate given string n number of times ; Function which return string by concatenating it . ; Copying given string to temporary string . ; s += s1 ; Concatenating strings ; Driver code
#include <bits/stdc++.h> NEW_LINE #include <string> NEW_LINE using namespace std ; string repeat ( string s , int n ) { string s1 = s ; for ( int i = 1 ; i < n ; i ++ ) return s ; } int main ( ) { string s = " geeks " ; int n = 3 ; cout << repeat ( s , n ) << endl ; ; return 0 ; }