Easiest way to convert string-of-integers to int
<p>I have a very long number with hundreds of digits which I have stored in a string.
Now, I want to read it into an integer/long digit-by-digit.</p>

<p><code>long int strtol ( const char * str, char ** endptr, int base );</code> 
takes an <strong>end-pointer</strong>, but it doesn't seem like I can set it right, because it tries to read in all digits, and hence, returns <code>LONG_MAX</code>.</p>

<pre><code>char str[]=
"70172427121883998797908792274921901699720888093776\
65727333001053367881220235421809751254540594752243\
52584907711670556013604839586446706324415722155397\
53697817977846174064955149290862569321978468622482\
83972241375657056057490261407972968652414535100474\
82166370484403199890008895243450658541227588666881\
16427171479924442928230863465674813919123162824586";

char *pEnd; //set pEnd to str[1]'s address how???
long num = strtol(str, &amp;pEnd,  10);
cout &lt;&lt; num &lt;&lt; endl; //LONG_MAX
</code></pre>

<p>I thought of solutions like copying it to a new character array, and then applying <code>strtol</code> but that doesn't seem like the best way to do it.</p>

<p>So what would be the easiest/best way to do this?</p>
