#include <iostream>
#include <string>
using namespace std;
/**
Returns a string of asterisks of the same length as
a given string.
@param str a string such as "secret"
@return a string with each character of str changed to a *,
such as "******".
*/
string hide_characters(string str)
{
string result;
for (char ch [[maybe_unused]] : str) {
result += '*';
}
return result;
}
int main()
{
string s = "Hello";
cout << s << endl;
cout << hide_characters(s) << endl;
s = "Goodbye";
cout << s << endl;
cout << hide_characters(s) << endl;
s = "Now is the time for all good men to come to the aid of their country.";
cout << s << endl;
cout << hide_characters(s) << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: