converts a string of digits str into an equivalent integer: - C String

C examples for String:String Function

Description

converts a string of digits str into an equivalent integer:

int atoi(char str[])
{
  int j, n = 0;
  for(j=0; str[j] >= '0' && str[j] <= '9'; ++j)
    n = 10 * n + (str[j] - '0');
  return n;
}

Related Tutorials