user18795: There is String.toInt(), but no String.toLong() or the many other variations. Do I have to resort to atol(String.c_str()) or is there a better way to convert a String to a long?

user76090: So the answer is: use String.toInt().
Probably not, as this is the definition of a String method:
long String::toInt(void) const
The real work is:
atol(buffer);
ASCII to long.

user10794: Using atol(String.c_str()) looks OK to me. If there was a String.toLong() it would be written that way anyway.
In fact, looking at the code for String.toInt() that's exactly what it does:
long String::toInt(void) const
{
    if (buffer) return atol(buffer);
    return 0;
}

So the answer is: use String.toInt().

18795: <p>There is <code>String.toInt()</code>, but no <code>String.toLong()</code> or the many other variations. Do I have to resort to <code>atol(String.c_str())</code> or is there a better way to convert a <code>String</code> to a long?</p>
 76090: <p>So the answer is: use String.toInt().</p>
<p>Probably not, as this is the definition of a String method:</p>
<p>long String::toInt(void) const</p>
<p>The real work is:</p>
<p>atol(buffer);</p>
<p>ASCII to long.</p>
 10794: <p>Using <code>atol(String.c_str())</code> looks OK to me. If there was a <code>String.toLong()</code> it would be written that way anyway.</p>

<p>In fact, looking at the code for <code>String.toInt()</code> that's exactly what it does:</p>

<pre><code>long String::toInt(void) const
{
    if (buffer) return atol(buffer);
    return 0;
}
</code></pre>

<p>So the answer is: use <code>String.toInt()</code>.</p>
