atoi
is perfect in this case, however there are other functions which you may find usefull in the future for similar tasks
strtol
- "string to long"
strtoul
- "string to unsigned long"
strtod
- "string to double"
These functions take a
char **_EndPtr
parameter which on return holds the position that the new string pointer after the number processed. This is helpful if you have a number in a string.
strtol
and
strtoul
take the radix as an additional parameter to specify the number base of the string so you can convert binary, octal, decimal, hexadecimal or any other base string to its integer equivalent
check out their pages on MSDN:
atoi[
^],
strtol[
^],
stroul[
^],
strtod[
^]