/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strlib.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tischmid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/01 07:13:31 by tischmid #+# #+# */ /* Updated: 2023/04/01 17:20:44 by tischmid ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_strlib.h" void ft_putchar(char c) { write(1, &c, 1); } void ft_putstr(char *str) { while (*str) ft_putchar(*str++); } void ft_putnbr(int nb) { if (nb > 9) { ft_putnbr(nb / 10); ft_putchar(nb % 10 + '0'); } else if (nb == INT_MIN) { ft_putnbr(nb / 10); ft_putnbr(-(nb % 10)); } else if (nb < 0) { ft_putchar('-'); ft_putnbr(-nb); } else ft_putchar(nb % 10 + '0'); } int puterr(char *errmsg, int errcode) { ft_putstr(RED); ft_putstr(errmsg); ft_putstr(RESET); return (errcode); } int ft_strcmp(char *s1, char *s2) { while (*s1 && *s2 && *s1 == *s2) { ++s1; ++s2; } return (*s1 - *s2); }