title: How to properly use getline in c++
body: <p>I am trying to for loop a string and put it inside a map in C++ but for some reason, it keeps excluding <code>myMap[0]</code> and I can't output the first letter of my strings. Please help.</p>
  
  <pre><code> #include &lt;iostream&gt;
   #include &lt;fstream&gt;
   #include &lt;cstdlib&gt;
   #include &lt;string&gt;
   #include &lt;map&gt;
   using namespace std;
  
   int main(int argc, char *argv[])
   {
  
      int inputNumbers;
      map&lt;int,string&gt;myMap;
  
      cout&lt;&lt;"Enter how many words"&lt;&lt;endl;
      cin&gt;&gt;inputNumbers;
      //insert the words to the map
      for(int i = 0; i &lt; inputNumbers; i++) {
  
          string inputNames ="";
          cout&lt;&lt;"Enter the word #"&lt;&lt;i+1&lt;&lt;" out of "&lt;&lt;inputNumbers&lt;&lt;endl;
  
          getline(cin, inputNames);
          myMap[i] = inputNames;
  
          cin.clear();
          cin.ignore();
      }
  
      //output map
      for(map&lt;int,string&gt;::iterator it = myMap.begin(); it != myMap.end(); it++)
          cout &lt;&lt; it-&gt;first &lt;&lt; ":" &lt;&lt; it-&gt;second &lt;&lt; endl;
      it-&gt;first &lt;&lt; ":" &lt;&lt; it-&gt;second &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>And this is the output</p>
  
  <pre><code> Enter how many words
   4
   Enter the word #1 out of 4
   Kobe
   Enter the word #2 out of 4
   is
   Enter the word #3 out of 4
   the greatest
   Enter the word #4 out of 4
   ever!!!
   0:
   1:obe
   2:s
   3:he greatest
   Program ended with exit code: 0
  </code></pre>
  
  <p>Would also appreciate an extra tip that scans a user input string and output if  it is a string word (no whitespace), real word (only letters), goodword (letters and numbers), capword (begins with a capital letter), acronym (all caps string).</p>