- #1
ineedhelpnow
- 651
- 0
Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:
"Hello! I'm Miley! Nice to meet you!"
Sample program:
#include <iostream>
#include <string>
using namespace std;
void MakeSentenceExcited(string& sentenceText) {
<STUDENT CODE>
}
int main() {
string testStr;
testStr = "Hello. I'm Miley. Nice to meet you.";
MakeSentenceExcited(testStr);
cout << testStr;
return 0;
}i came up with
int pos = sentenceText.find('.');
while()
{
sentenceText.replace(pos, 1, "!");
pos = sentenceText.find('.', pos+1);
}
but i don't know what goes int he while loop. please help. its almost due...
"Hello! I'm Miley! Nice to meet you!"
Sample program:
#include <iostream>
#include <string>
using namespace std;
void MakeSentenceExcited(string& sentenceText) {
<STUDENT CODE>
}
int main() {
string testStr;
testStr = "Hello. I'm Miley. Nice to meet you.";
MakeSentenceExcited(testStr);
cout << testStr;
return 0;
}i came up with
int pos = sentenceText.find('.');
while()
{
sentenceText.replace(pos, 1, "!");
pos = sentenceText.find('.', pos+1);
}
but i don't know what goes int he while loop. please help. its almost due...