Hi, I have a question concerning chaining functions. Here is my code below:
Code:
#include <iostream>
#include <string>
using namespace std;
string enter_secret();
string hidden_word();
string word, secret;
int main()
{
enter_secret();
return 0;
}
string enter_secret()
{
cout << "Enter a word" << endl;
cin >> word;
string str (word);
cout << "String Length: " << str.length() << endl;
return secret;
}
string hidden_word(string secret)
{
return string(secret.length(), '-');
}
Now when I run the program, it would ask me to enter a word, then it would output the number of strings the word has.
So for example, the word trees have five letters so the answer is five.
Now how would we hook that to the function below called string hidden_word(string secret)?
I want the program to also output the number of dashes in place of the number of letters.
How would we hook the function string hidden_word to main? Or should it get hooked to the function enter_secret?
Thanks.