Created
June 9, 2014 16:59
-
-
Save cynx/296b6b2bb9c733f16187 to your computer and use it in GitHub Desktop.
C program to convert string of numbers to their numeric equivalent
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
#include <stdio.h> | |
int main() | |
{ | |
int atoi (char s[]); | |
printf("%d",atoi("239")); | |
return 0; | |
} | |
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'); | |
return n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment