/* ECP: FILEname=fig11_4.c */ /* 1*/ /* Print N In Any Base */ /* 2*/ static char DigitTable[ ] = "0123456789abcdef"; /* 3*/ static const MaxBase = sizeof( DigitTable ) - 1; /* 4*/ static void /* 5*/ PrintInt1( unsigned int N, unsigned int Base ) /* 6*/ { /* 7*/ if( N >= Base ) /* 8*/ PrintInt1( N / Base, Base ); /* 9*/ putchar( DigitTable[ N % Base ] ); /*10*/ } /*11*/ void /*12*/ PrintInt( unsigned int N, unsigned int Base ) /*13*/ { /*14*/ if( Base <= 1 || Base > MaxBase ) /*15*/ printf( "Can not print in base %u\n", Base ); /*16*/ else /*17*/ PrintInt1( N, Base ); /*18*/ }