title: Convert string to integer recursively?
body: <p>Here is a simple function that converts a string to an integer.  </p>
  
  <pre><code>int str2int(char *str)
  {
      int ret = 0;
      char *c;
  
      for (c = str; (*c != '\0') &amp;&amp; isdigit(*c); ++c)
          ret = ret*10 + *c - '0';
  
      return ret;
  }
  </code></pre>
  
  <p>As an exercise, I'd like to write a recursive function that does the same thing. This is what I came up with.</p>
  
  <pre><code>int str2int2(char *c, int *i)
  {
      if (*c == '\0' || !isdigit(*c))
          return *i;
  
      *i = *i * 10 + *c - '0';
  
      return str2int2(c + 1, i);
  }
  
  .
  .
  int i = 0;
  .
  ... str2int2(str, &amp;i);
  </code></pre>
  
  <p>Is there a way to write the recursive function without using the extra <code>int*</code> argument?</p>