eg0rmaffin

putnbr

Jul 8th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3.  
  4.  
  5. int ft_putchar(char c)
  6. {
  7.     write (1, &c, 1);
  8.     return 0;
  9. }
  10.  
  11. void    ft_putnbr(int nb)
  12. {
  13.     if (nb == -2147483648)
  14.     {
  15.         ft_putchar ('-');
  16.         ft_putchar ('2');
  17.         ft_putnbr (147483648);
  18.     }
  19.     else if (nb > 9)
  20.     {
  21.         ft_putnbr(nb / 10);
  22.         ft_putnbr(nb % 10);
  23.     }
  24.     else
  25.     {
  26.         ft_putchar(nb + '0');
  27.     }
  28. }
  29.  
  30.  
  31.  
  32.  
  33. int main(){
  34.     int a = -2147483648;
  35.     ft_putnbr(a);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment