daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char* destBase(int decimalnum , int destbase){ //Destination convertion
  2.     int i,tmp ,size;
  3.     char* ans;
  4.     size=((int)(log(decimalnum)/log(destbase)) +1);
  5.     ans=(char*)malloc(size*sizeof(char));
  6.     for(i=strlen(ans)-1 ; decimalnum>0 ; i++){
  7.         tmp=decimalnum%destbase;
  8.         if(tmp>=0 && tmp <= 9){
  9.             ans[i]=tmp+'0';
  10.         }
  11.         else if(tmp>='A'-10 && tmp <='Z'-10){
  12.             ans[i]=tmp+'A'-10;
  13.         }
  14.         else if(tmp >='a'-10 && tmp <='z'-10){
  15.             ans[i]=tmp+'a'-10;
  16.         }
  17.         decimalnum=decimalnum/destbase;
  18.     }
  19.  
  20.     return ans;
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top