title: Convert string from getline into a number
body: <p>I am trying to create a 2D array with vectors. I have a file that has for each line a set of numbers. So what I did I implemented a split function that every time I have a new number (separated by <code>\t</code>) it splits that and add it to the vector</p>
  
  <pre><code>vector&lt;double&gt; &amp;split(const string &amp;s, char delim, vector&lt;double&gt; &amp;elems) {
      stringstream ss(s);
      string item;
      while (getline(ss, item, delim)) {
          cout &lt;&lt; item &lt;&lt; endl;
          double number = atof(item.c_str());
          cout &lt;&lt; number;
          elems.push_back(number);
      }
      return elems;
  }
  
  
  vector&lt;double&gt; split(const string &amp;s, char delim) {
      vector&lt;double&gt; elems;
      split(s, delim, elems);
      return elems;
  }
  </code></pre>
  
  <p>After that I simply iterate through it.</p>
  
  <pre><code>int main()
  {
      ifstream file("./data/file.txt");
      string row;
      vector&lt; vector&lt;double&gt; &gt; matrix;
  
      int line_count = -1;
      while (getline(file, row)) {
          line_count++;
          if (line_count &lt;= 4) continue;
          vector&lt;double&gt; cols = split(row, '\t');
          matrix.push_back(cols);
      }
  ...
  }
  </code></pre>
  
  <p>Now my issues is in this bit here:</p>
  
  <pre><code>   while (getline(ss, item, delim)) {
          cout &lt;&lt; item &lt;&lt; endl;
          double number = atof(item.c_str());
          cout &lt;&lt; number;
  </code></pre>
  
  <p>Where item.c_str() is converted to a 0. Shouldn't that be still a string having the same value as item? It works on a separate example if I do straight from string to c_string, but when I use this getline I end up in this error situation, </p>
  
  <p>hints?</p>