non-contiguous '0' .. '9'

Alan J Rosenthal flaps at dgp.toronto.edu
Thu Aug 31 04:32:12 AEST 1989


I think the point wrt non-contiguous '0'..'9' is that you don't really gain
anything if they're contiguous.  Instead of
	#define val(c) ((c) - '0')
you can just use
	char digits[] = "0123456789";
	#define val(c) (strchr(digits, (c)) - digits)
and instead of
	#define str(n) ((n) + '0')
you can just use
	#define str(n) (digits[n])

ajr



More information about the Comp.lang.c mailing list