Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. char    *convert_base(char *nbr, char *base_from, char *base_to)
  2. {
  3.   int   i;
  4.   int   nb;
  5.   char  *res;
  6.  
  7.   i = 0;
  8.   res = malloc(sizeof(char) * 300);
  9.   nb = my_getnbr_base(nbr, base_from);
  10.   while (nb > 0)
  11.     {
  12.       res[i] = base_to[nb % my_strlen(base_to)];
  13.       nb = nb / my_strlen(base_to);
  14.       i = i + 1;
  15.     }
  16.   res[i] = '\0';
  17.   res = my_revstr(res);
  18.   return (res);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement