Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <unistd.h>
  2. void my_putstr(char *str);
  3. void my_putchar(char c);
  4. void my_put_nbr(int n)
  5. {
  6. int i;
  7.  
  8. i = 1;
  9. if (n == -2147483648)
  10. {
  11. my_putstr("-2147483648");
  12. }
  13. else
  14. {
  15. if (n < 0)
  16. {
  17. my_putchar('-');
  18. n *= -1;
  19. }
  20. while ((n / i) >= 10)
  21. i *= 10;
  22. while (i > 0)
  23. {
  24. my_putchar((n / i) % 10 + '0');
  25. i /= 10;
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement