summaryrefslogtreecommitdiff
path: root/sample/atou.c
blob: 36585990856df803ce5152b31161f1c4e034d645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
static inline int
isdigit(int ch)
{
  return (ch >= '0') && (ch <= '9');
}

unsigned int atou(const char *s)
{
  unsigned int i = 0;
  while (isdigit(*s))
    i = i*10 + (*s++ - '0');
  return i;
}