Wednesday, 28 June 2017

Convert Num, to base

char *convert(unsigned int num, int base)
{
   static char buf[33];
   char *ptr;

   ptr=&buf[sizeof(buff)-1];
   *ptr='\0';
   do
    {
      *--ptr="0123456789abcdef"[num%base];
      num/=base;
    }while(num!=0);
   return(ptr);
} 

No comments:

Post a Comment