Oscar A.

asked • 04/06/20

Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes

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!"

#include <iostream>

#include <cstring>

using namespace std;


void MakeSentenceExcited(char* sentenceText) {


for (int i = 0; i < sentenceText.lenth(); i++){

if (sentenceText.at(i) == '.'){

sentenceText.at(i) = '!';

}

}

return;


}


int main() {

const int TEST_STR_SIZE = 50;

char testStr[TEST_STR_SIZE];


cin.getline(testStr, TEST_STR_SIZE);

MakeSentenceExcited(testStr);

cout << testStr << endl;


return 0;

} This is my code but I keep getting an error.


Here is the template

#include <iostream>

#include <cstring>

using namespace std;


void MakeSentenceExcited(char* sentenceText) {


/* Your solution goes here */


}


int main() {

const int TEST_STR_SIZE = 50;

char testStr[TEST_STR_SIZE];


cin.getline(testStr, TEST_STR_SIZE);

MakeSentenceExcited(testStr);

cout << testStr << endl;


return 0;

}

1 Expert Answer

By:

Patrick B. answered • 04/06/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.