Ok. I tried the following:
Code:
/* a function to write a string a given number of times, as specified in a
second parameter */
#include <iostream>
#include <string>
using std::cout; using std::endl;
using std::cin; using std::string;
void output(string, int);
int main()
{
int n = 0;
cout << "Write something: ";
string input;
cin >> input;
cout << "Number of times to display it: ";
cin >> n;
output(input, n);
return 0;
}
void output(string input, int n)
{
for(int i = 0; i < n; i++)
cout << input + '\n' * n;
}
But I get the following error from the compiler:
Code:
ex5-2c.cc: In function `void output(basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> >, int)':
ex5-2c.cc:29: no match for `string & + int'