Question: Write a C++ program that capitalizes the first letter of every sentence. The program must be written in accordance to the following plan: Write A
Write a C++ program that capitalizes the first letter of every sentence. The program must be written in accordance to the following plan:
Write A Function Prototype
Write a function prototype for the function named sentenceCapitalizer. The function receives a char * pointer as the parameter for the beginning of a C-string. The function does not have any value to return.
Write The Main Function
Define and initialize a char array named userString using the following string literal as the initial value.
"no, not tonight. it's a very popular place \ and you have to make reservations in advance. besides, \ it's expensive, and I don't have any money."
Note. The string literal has been separated into three lines using the back slash character '\' as the continuation marker. The second and third lines should start with the first column of the line.
Print the unmodified C-string to the screen.
Call the function sentenceCapitalizer to perform the capitalization.
Print the modified C-string to the screen.
Write the function definition for sentenceCapitalizer
Write the block comment that describes the function name, what the function does, the parameter and the return value. In this case, simply write there is no returned value.
In the function body, use the pointer parameter to walk through the C-string. For each character in the C-string, determine whether it is the first letter of a sentence and capitalize it accordingly. The sentences may be separated with any number of spaces. Your algorithm should not assume that the first letter is always one space away from the end of a sentence marker.
Test the program
The output should look exactly as follows.
The text before the modification: no, not tonight. it's a very popular place and you have to make reservations in advance. besides, it's expensive, and I don't have any money. The text after the modification: No, not tonight. It's a very popular place and you have to make reservations in advance. Besides, it's expensive, and I don't have any money.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
