9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
guia08/ex07.c (323B)
   1 #include <stdio.h>
   2 #include <stdlib.h>
   3 
   4 #define INT_MAX_HEX_DIGITS 4
   5 
   6 char *itoo(int n);
   7 
   8 int main (void)
   9 {
  10     char *arr;
  11     arr = itoo(32155);
  12     printf("%s\n", arr);
  13 
  14     free(arr);
  15     return 0;
  16 }
  17 
  18 char *itoo(int n)
  19 {
  20     char *arr;
  21 
  22     arr = (char *)calloc(INT_MAX_HEX_DIGITS + 1, sizeof(char));
  23     sprintf(arr, "%X", n);
  24 
  25     return arr;
  26 }