Write a program that uses regular ex- pressions to convert the first letter of all words to uppercase. Have it do this for an arbitrary string input by the user.

What will be an ideal response?


```
#include
#include
#include
#include
using namespace std;

int main()
{
string sentence, output;

// get the sentence from the user
cout << "Please enter a sentence: ";
getline( cin, sentence );

// split the sentence into words
boost::sregex_token_iterator tokens( sentence.begin(), sentence.end(),
boost::regex( "\\s" ), -1 );
boost::sregex_token_iterator end;

// while there are still tokens left
while ( tokens != end )
{
string word = *tokens;
word[0] = toupper( word[0] ); // make the first letter uppercase
output += word + " "; // add the word to the output
++tokens;
} // end while

// display the output string
cout << output << endl;
} // end main
```
Please enter a sentence: this is a sentence with several words
This Is A Sentence With Several Words

Computer Science & Information Technology

You might also like to view...

You do not need to be in symbol-editing mode to modify a button.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The ________ hides tools and menus to make more room for the pages themselves

A) Normal view B) Print Layout view C) Read Mode D) Outline view

Computer Science & Information Technology

Among the options shown in the accompanying figure, the ____ option tracks values over time.

A. Bar B. Area C. Pie D. Line

Computer Science & Information Technology

You can use the Text property of a Label object to change the size and appearance of the text.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology