user33435: I'm trying to use strtoul() to convert an Arduino String to an unsigned long (like the return of millis();) using the following code snippet:
unsigned long foo (String time)
{
  unsigned long mili;
  char Tim[9]="";
  uint16_t timsize = time.length()+1;
  char TIM[timsize];
  time.toCharArray(TIM,timsize);
  mili=strtoul(TIM,timsize,10);
  return mili;
}

The code seems to work. However, I'm getting the following warning:

invalid conversion from 'uint16_t {aka unsigned int}' to 'char**' [-fpermissive] mili=strtoul(TIM,timsize,10);


My question is twofold:

Is there a better way to convert a String to unsigned long without first converting to a C string?
If not, how can I eliminate this error?


user23841: Arduino String class provides method c_str(). So you don't have to convert it to C string, as it's already stored as a C string internally.
And as mentioned in comments, the second parameter of strtoul is:

endptr
      Reference to an object of type char*, whose value is set by the function to the next character in str after the numerical value.
      This parameter can also be a null pointer, in which case it is not used.

Basically you can reduce whole foo to the:  return strtoul(time.c_str(), NULL, 10);

33435: <p>I'm trying to use <code>strtoul()</code> to convert an Arduino <strong>S</strong>tring to an unsigned long <em>(like the return of <code>millis();</code>)</em> using the following code snippet:</p>

<pre><code>unsigned long foo (String time)
{
  unsigned long mili;
  char Tim[9]="";
  uint16_t timsize = time.length()+1;
  char TIM[timsize];
  time.toCharArray(TIM,timsize);
  mili=strtoul(TIM,timsize,10);
  return mili;
}
</code></pre>

<p>The code seems to work. However, I'm getting the following warning:</p>

<blockquote>
  <p>invalid conversion from 'uint16_t {aka unsigned int}' to 'char**' [-fpermissive] <code>mili=strtoul(TIM,timsize,10);</code></p>
</blockquote>

<hr>

<p>My question is twofold:</p>

<ol>
<li><p>Is there a better way to convert a <strong>S</strong>tring to unsigned long without first converting to a C string?</p></li>
<li><p>If not, how can I eliminate this error?</p></li>
</ol>
 23841: <p>Arduino <code>String</code> class provides method <code>c_str()</code>. So you don't have to convert it to C string, as it's already stored as a C string internally.</p>

<p>And as mentioned in comments, the second parameter of <code>strtoul</code> is:</p>

<blockquote>
  <p><strong>endptr</strong><br>
      Reference to an object of type <code>char*</code>, whose value is set by the function to the next character in str after the numerical value.<br>
      This parameter can also be a null pointer, in which case it is not used.</p>
</blockquote>

<p>Basically you can reduce whole foo to the:  <code>return strtoul(time.c_str(), NULL, 10);</code></p>
