itoa without strrev.

While looking through my old code (I do this often when I'm bored) I came across an implementation of itoa, which doesn't reverse the string.
1
2
3
4
5
6
7
8
9
10
11
char * itoa(int i,int base){
	static char s[34];
	char*t=s+32;
	int sgn=i>=0?1:-1;
	i/=sgn;
	do*t--="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz+/"[i%base];while(i/=base,i>0);
	if(sgn<0)*t='-';
	else++t;
	return t;
}

What do you think?
closed account (E60S216C)
Huh? That code makes no sense.....to me.
Actually, as cryptographic as it may be, it is still nice in some weird way. However, because you output in reverse direction, you can not control the starting position. This may be a problem if you want to write the digits at specific place in some other string (like a line of output). It is inconvenient for use with STL also. But it suits my taste.

Regards
Topic archived. No new replies allowed.