Im writing a progrem that takes input (a sentence) from the user and I about it in the proper format. All i need now is to figure out how to get the spacing correct in the sentence. I need all the strings of two or more blank spaces should be compressed to one single space. Here is what I got so far. Any ideas on how to go about doing the spacing would be greatly appreciated. Thanks!!
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string str;
cout << "Enter your sentence and then press enter. " << endl;
getline (cin, str);
str[0] = toupper (str[0]);
for (int i = 1; i < str.length(); i++)
{
str[i] = tolower (str[i]);
}
cout << str << endl;
}