Skip to content

Instantly share code, notes, and snippets.

@cynx
Created June 9, 2014 16:59
Show Gist options
  • Save cynx/296b6b2bb9c733f16187 to your computer and use it in GitHub Desktop.
Save cynx/296b6b2bb9c733f16187 to your computer and use it in GitHub Desktop.
C program to convert string of numbers to their numeric equivalent
#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