title: C++ error converting a string to a double
body: <p>I am trying to convert a string to a double.  The code is very simple.  </p>
  
  <pre><code>            double first, second;
              first=atof(str_quan.c_str());
              second=atof(extra[i+1].c_str());
              cout&lt;&lt;first&lt;&lt;" "&lt;&lt;second&lt;&lt;endl;
              quantity=first/second;
  </code></pre>
  
  <p>when trying to convert extra, the compiler throws this gem of wisdom at me:</p>
  
  <blockquote>
    <p>error: request for member c_str in
    extra.std::basic_string&lt;_CharT,
    _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = std::char_traits, _Alloc =
    std::allocator](((unsigned
    int)(i + 1))), which is of non-class
    type char</p>
  </blockquote>
  
  <p>I have no idea what that means.  if I cout extra[i+1], I get 3.  If I leave extra as a string, the program tries to div first (2) by 51 (ascii for 3).  What the heck is going on?</p>