26 lines
360 B
C
26 lines
360 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int toInt(char *s)
|
|
{
|
|
int ret = 0, base = 1;
|
|
int len;
|
|
|
|
len = strlen(s);
|
|
while (s[--len] >= '0')
|
|
{
|
|
ret += (s[len] - '0') * base;
|
|
base *= 10;
|
|
}
|
|
|
|
if (s[0] == '-')
|
|
ret *= -1;
|
|
|
|
return (ret);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
printf("%d\n", toInt(argv[1]));
|
|
}
|