title: getline() throwing strange error in combination with stoi()
body: <p>I'm having a strange issue with stoi().  Heres my code:</p>
  
  <pre><code>ifstream bookStream("inventory.txt", ios::in);
  book tempBook;
  
  string tmp;
  if (bookStream.is_open())
      while (!bookStream.eof()) {
          getline(bookStream, tmp, '#');
          //cout &lt;&lt; tmp &lt;&lt; endl;
          tempBook.bookId = stoi(tmp);
  
  
          getline(bookStream, tempBook.title, '#');
          tempBook.title = tmp;
          getline(bookStream, tempBook.author, '#');
          tempBook.author = tmp;
          getline(bookStream, tmp, '#');
          tempBook.cost = stof(tmp);
          getline(bookStream, tmp, '#');
          tempBook.price = stof(tmp);
          getline(bookStream, tmp, '#');
          tempBook.quantity = stoi(tmp);
  
      }
  else
      cout &lt;&lt; "error opening file" &lt;&lt; endl;
  </code></pre>
  
  <p>I get a runtime error (abort has been called).  If I comment the bottom half of the code and just run:</p>
  
  <pre><code>getline(bookStream, tmp, '#');
  cout &lt;&lt; tmp &lt;&lt; endl;
  </code></pre>
  
  <p>in the while loop it will print out every string just how it should, with integers and strings sperated on each line and no '#'.  Even if i commented everything but the first stoi() it will throw the same error.</p>
  
  <p>Here are a couple lines from my inventory.txt:</p>
  
  <pre><code>116807#A Tale of Two Cities#Charles Dickens#3.73#9.99#1
  111272#The Iliad#Homer#2.78#9.99#10
  164440#The Great Gatsby#F. Scott Fitzgerald#4.92#9.99#8
  </code></pre>
  
  <p>output of <code>cout &lt;&lt; tmp &lt;&lt; endl;</code></p>
  
  <p><a href="http://i.imgur.com/4Tn4Rd8.png" rel="nofollow">http://i.imgur.com/4Tn4Rd8.png</a></p>