Repeat a String
Lesson 2 of 18 in Coddy's Functions in C++: Building Your Own Functions course.
Challenge
EasyWrite a function to repeat a string a given number of times with a specific separator.
The repeat_string function is a function that takes a string and repeats it a specified number of times with a specific separator in between each repetition.
For example, if the string is "Coddy", the number of repetitions is 3, and the separator is "@", the result will be:
Coddy@Coddy@CoddySet the default number of repetitions to 2 and the separator to "$". So, by default, if the string is "Coddy", the result will be:
Coddy@CoddyTry it yourself
#include <iostream>
using namespace std;
string repeat() {
}All lessons in Functions in C++: Building Your Own Functions
1Introduction
Introduction2Beginner-level function
Repeat a StringReverse a StringMax ValueFill stringCenter TextFormat TextMath Operation