title: Convert C++ string variable to long
body: <p>I have a variable: </p>
  
  <pre><code>string item;
  </code></pre>
  
  <p>It gets initialized at run-time. I need to convert it to long. How to do it? I have tried atol() and strtol() but I always get following error for strtol() and atol() respectively:</p>
  
  <pre><code>cannot convert 'std::string' to 'const char*' for argument '1' to 'long int strtol(const char*, char**, int)'
  
  cannot convert 'std::string' to 'const char*' for argument '1' to 'long int atol(const char*)'
  </code></pre>