title: How to Remove the Ending Space of the Output of this Code
body: <p>Output ends in a sentence and then a final space at the end that I need removed. Help please! I'm stumped! I know it's in the cout at the end, but if I remove that final space, then the entire output sentence comes without spaces. It's my first time doing C++ so I'm a total beginner at this and literally have no idea what to do right now.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  #include&lt;sstream&gt;
  #include&lt;algorithm&gt;
  #include&lt;iterator&gt;
  #include&lt;map&gt;
  
  using namespace std;
  
  map&lt;string, string&gt; myMap;
  
  int contains(string str) {
       map&lt;string,string&gt;::iterator it = myMap.find(str);
       if(it != myMap.end())
       {
       return 1;
       }
       return 0;
       }
  
   int main() {
  
       myMap["BFF"] = "best friend forever";
       myMap["IDK"] = "I don't know";
       myMap["JK"] = "just kidding";
       myMap["TMI"] = "too much information";
       myMap["TTYL"] = "talk to you later";
       myMap["IDK."] = "I don't know.";
       myMap["TTYL."] = "talk to you later.";
       myMap["BFF,"] = "best friend forever,";
       myMap["JK,"] = "just kidding,";
       myMap["JK."] = "just kidding.";
       myMap["TMI!"] = "too much information!";
       myMap["TMI."] = "too much information.";
  
  
      string text;
  
      cout &lt;&lt; "Enter text: ";
      getline(cin, text);
      cout &lt;&lt; "You entered: " &lt;&lt; text &lt;&lt; endl;
      cout &lt;&lt; "Expanded: ";
  
   stringstream ss(text);
   string item;
   while (getline(ss, item, ' ')) {
       if(contains(item) == 1) {
           cout &lt;&lt; myMap[item] &lt;&lt; " ";
      } 
      else {
           cout &lt;&lt; item &lt;&lt; " ";
       }
  
  }
  
  
  cout &lt;&lt; endl;
  
  
  }
  </code></pre>