Advertisement
Guest User

c-code-convert-binaire

a guest
Sep 25th, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7. int * convert ( int iNumber, int iBase )
  8. {
  9.     int * cResult = malloc(sizeof(int)*sizeof(int));
  10.     int iCompteur = 0;
  11.    
  12.     if ( cResult != NULL )
  13.     {
  14.         while ( iNumber != 0 ) {
  15.             cResult[iCompteur] = iNumber % iBase;
  16.             iNumber = iNumber / iBase;
  17.             iCompteur++;
  18.            
  19.         }
  20.         //iCompteur = iCompteur - 1;
  21.         //int p = cResult;
  22.         //while ( iCompteur >= 0 ) {
  23.         //p = cResult[iCompteur];
  24.         //printf("%d", p);
  25.         //iCompteur--;
  26.         //}
  27.        
  28.          
  29.     }
  30.     return cResult;
  31. }
  32.  
  33. int main (int argc, const char * argv[])
  34. {
  35.  
  36.     // insert code here...
  37.     int iNumbre = convert(2,2);
  38.     printf("%d", iNumbre);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement