Please read my entire question:
My main function works properly. But I need it to be in the getSecretMessage(string str) function. How can I do that?
Again, the main function works fine so I don't need help finishing the main. I just need to move the logic I have from main into the string function.
/**
* Assignment#6.2
* DUE: 3/13/16
* NAME: <Joshua Cisneros>
* Purpose: Your professor needs your help to decipher some secret message in a sentence.
* The secret message is formed by taking the first letter from each word in the sentence,
* in the order they appear. Write the following function per its styling/documentation:
*
*/
#include <iostream>
usingnamespace std;
/**
* FUNCTION SIGNATURE: string getSecretMessage(string str)
* PURPOSE: get secret message by taking the first character from each word in the input sentence, in the order they appear
* PARAMETER:
* str, the input sentence
* RETURN VALUE:
* The secret message
*/
string getSecretMessage(string str)
{
}
int main (void) {
string str[51]; // the code works perfectly here though.
int i=0;
for (i=0;i<51;i++)
{
cin >> str[i];
}
for (i=0;i<51;i++)
{
cout << str[i][0];
}
return 0;
}
If I understand you are using an array to hold each word individually but the problem says that your string getSecretMessage(string str) function can only take one string. Instead of putting each word in an array try making the program with the entire sentence in one string.