This is excerpted from K&R pages. 42-43
The explanation reads that this function coverts a string of digits into its numeric equivalent.
Do they explicitly mean numbers by saying digits? If so, what does it's numeric equivalent mean if digits are already numbers?
I'm having problems understanding what is happening here:
int atoi(char s)
int i, n;
n = 0;
for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
n = 10 * n + (s[i] - '0');
It says that this gives the numeric value of the character stored in s[i], because the values of '0', '1', etc, form a contiguous increasing sequence.
I really don't understand that construct or what this is saying.
Help would be greatly appreciated.