I am writting a program that gets a line of input from a user and puts that in a string. Then it needs to correct whitespace and capitalization. If there is more then one space of whitespace between words change it to one space and if it is a period add a space.
this is what i have so far and Im trying to get the whitespace right.
this is what i have so far and Im trying to get the whitespace right.
Code:
#include<string>
#include<iostream>
using namespace std;
int main() {
cout << "enter sentence and hit enter";
string s1;
getline(cin,s1);
if(s1 != " ");
{
char seporator = ' ';
if (s1[s1.length()-1] == '.')
{ seporator = '\n';
}
cout << s1 << seporator;
}
while(s1 != " ");
return(0);
}
Comment