i wrote this programme that will read a sentence from standard input and output the sentence with spacing corrected and letters corrected for capitalization. in other words if the input sentence has spaces between words composed of more than one blank in the ouput sentence these spaces should be compressed into onto one single blank. the sentence should start with uppercase letter and then contain no other uppercase letter.
But im not able to store the whole sentence?only one word is converted.
Code:#include <iostream> using namespace std; int main() { string str; cin >> str; cout << "Before: " << str << endl; str[0] = toupper(str[0]); // Capitalize first letter if (str[str.size()-1] != '.') str += '.'; // Add period at end of string for(size_t i = 1; i < str.size(); i++) str = tolower(str); // Lower case all letters other than the first. cout << "After : " << str; return 0; }