Created
October 12, 2013 09:08
-
-
Save jeonghwan-kim/6947738 to your computer and use it in GitHub Desktop.
Convert string to integer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int str_to_int(char *str) { | |
int i = 0; | |
while (*str >= '0' && *str <= '9') | |
i = i * 10 + *str++ - '0'; | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment