spielplatz:student:42:putnumber
get a number on Terminaloutput
- putnbr.c
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgehrman <sgehrman@student.42berlin.d +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/02/07 22:59:59 by sgehrman #+# #+# */
/* Updated: 2026/02/16 17:53:48 by sgehrman ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putnbr(int nb)
{
long n;
char c;
n = nb;
if (n > 2147483647)
{
write(STDOUT_FILENO, "INT_MAX", 7);
}
if (n < 0)
{
write(STDOUT_FILENO, "-", 1);
n *= -1;
}
if (n <= 9)
{
c = n + '0';
write(STDOUT_FILENO, &c, 1);
}
if (n > 9)
{
ft_putnbr(n / 10);
ft_putnbr(n % 10);
}
}
/*
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(int argc, char *argv[])
{
(void) argc;
(void) **argv;
ft_putnbr(234);
ft_putnbr(-1);
printf("\n%d\n", INT_MAX);
ft_putnbr(-234);
ft_putnbr(42);
return (0);
}
*//* INT_MAX #include <limits.h> n = (int)argc;*/
/volume1/web/dokuwiki/data/pages/spielplatz/student/42/putnumber.txt · Zuletzt geändert: 2026/02/21 18:59 von 89.246.128.70