Which is faster?

My friend's friend made a function for inputing unsigned integers. It's faster than scanf and much faster than cin. But I made a small change and I think it's a bit faster now. But I'm not sure. Here's the old function:
1
2
3
4
5
6
7
8
int scanInt ()
{
char c;
while (!isdigit (c = getchar ()));
int ret = c - '0';
while (isdigit (c = getchar ())) ret = (ret * 10) + (c - '0');
return ret;
}

e.g.
 
int i = scanInt ();


Here is the new function:
1
2
3
4
5
6
7
void scanInt (int *i)
{
char c;
while (!isdigit (c = getchar ()));
*i = c - '0';
while (isdigit (c = getchar ())) *i = (*i * 10) + (c - '0');
}


e.g.
1
2
int i;
scanInt (&i);


It doesn't really matter, but I'm curious about which one is faster.
Cheers!
Topic archived. No new replies allowed.