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...

Select the item below that lists elements used in an HTML table:

a. table, head, tfoot b. table, tr, tt c. thead, body, tr d. table, tr, td

Computer Science & Information Technology

Adding five 20-page documents to the Book panel would create a book that is paginated from what to what?

What will be an ideal response?

Computer Science & Information Technology