#include <string>
#include <vector>
#include <iostream>

using namespace std;

int reverse_the_words_in_a_sentence()
{
   string input; // our input string
   vector<string> s_words; // to contain our words
   string new_word; // for building the words
   int count;

   cout << "Enter a sentance: ";
   getline (cin, input); // get our input

   for (int i = 0; i < input.size(); i++) // for each char in input
   {
      if (input.at(i) == ' ') // if char equal to space
      {
         if (new_word.size() > 0) // if we have something in new_word
         {
            s_words.push_back(new_word); // add it to our array
            new_word = ""; // clear new_word
            count++;
         }
         continue; // go to next iteration of loop
      }

      new_word += input.at(i); // add char to new_word
   }

   s_words.push_back(new_word); 

   cout << "Reversed sentance: " << endl;

   for (int i = count; i >= 0; i--) // for each word in reverse
      cout << s_words.at(i) << " "; // cout the word

   cout << endl; // and finally an endline

   return 0;
}
