title: Converting string to long
body: <p>I'm trying to convert a string to long. It sounds easy, but I still get the same error. I tried:</p>
  
  <pre><code>include &lt;iostream&gt;
  include &lt;string&gt;    
  
  using namespace std;
  
  int main()
  {
    string myString = "";
    cin &gt;&gt; myString;
    long myLong = atol(myString);
  }
  </code></pre>
  
  <p>But always the error:</p>
  
  <pre><code>.../main.cpp:12: error: cannot convert 'std::string {aka std::basic_string&lt;char&gt;}' to 'const char*' for argument '1' to 'long int atol(const char*)'
  </code></pre>
  
  <p>occured.
  The reference says following: </p>
  
  <pre><code>long int atol ( const char * str );
  </code></pre>
  
  <p>Any help?</p>