I cannot figure out how to compress my sentence to one word in lower case. I was able to make the sentence lower case but do not know how to compress it to one word and then reverse it.
This is what I have so far:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
// Declarations: Declaring variables
string sentence, choice, reversed_word, letter, lower_sentence;
int numletters, i;
char _1char;
do
{
cout << "Enter a sentence to check: " << endl;
getline(cin, sentence);
numletters = sentence.length();
for (i=0; i<= numletters; i++)
{
letter = tolower(sentence[i]);
lower_sentence = lower_sentence + letter;
This is needed because the newline character '\n' will remain in the input buffer and the next getline will read everything up to that newline, resulting in an empty string.