You enter a sentence which you must end with a period (full stop) "."
It makes the first character an upper case and converts all other character to lower case.
It checks for a " " character for some reason...
I assume you want to modify it to do something else?
So the code is an example of how to input a sentence and gives an example of how a sentence can be processed.
You need to insert code to process it the way you want.
Here is a simple example in which the process is to convert any lower case characters to upper case.
#include <iostream>
#include <string>
//#include <cctype>
usingnamespace std;
int main()
{
string one_line, sentence="";
cout <<"Enter a sentence and end it with a full stop"<<endl;
// get a sentence ending with a period (full stop).
do
{
getline(cin, one_line);
if (sentence.length()==0)
sentence=one_line;
else
sentence=sentence +" "+ one_line;
}while (one_line.find(".") == string::npos);
// convert any lowercase characters to uppercase characters
char current;
for (int i=0; i <sentence.length();i++)
{
sentence[i]= toupper(sentence[i]);
}
cout << sentence; // print the result
cout <<endl;
return 0;
}
Then you need to extract the words from the sentence and determine if they start with something other than a digit. One way might be to look for a space character after which you can check if the next character is a digit or not. Is that what the sample code you gave does?
Your first post did not make it clear that you were talking about more than just a character type.
Figure out how you would do it with pen and paper and convert those steps into C++ code.
Remember a string is just a list of characters and the variable i in the above examples points to the position in that list.