need help to develop a C++ program?

Develop a C++ program to:
• read a long character string from the keyboard
• print out the length of the string
• convert all uppercase letters to lower case
• remove all spaces and non-letters from the string

The length of the string is unknown.
Test your program on the following strings (type them in exactly)
A man, a Plan, a Canal – Panama!
Able was I, ere I saw Elba

i don't even know how to start.

Shawn B2012-04-11T10:21:25Z

Favorite Answer

To read a line of text from the keyboard, just use cin.getline(). This will allow any length of text typed, and when the user presses the Enter key, you get the line of text.

Just use the STL string class 'std::string', which has a length() function. So, you will know the length of the string.

Converting to lower case is done in a tricky way. see this example:
std::string myStr = "This is a test.";
transform(myStr.begin(), myStr.end(), myStr.begin(), tolower);

To remove not-letter characters, there may be a tricky way to do this. But, a simple way would be as follows:
std::string newStr;
for (int i=0; i<myStr.length(); ++i)
{
char ch = myStr[i];
if (isalpha(ch)) newStr += ch;
}

Now the string newStr has the text with only alphabetic characters.