Compare commits
3 Commits
038cded5c0
...
6546e29ae5
| Author | SHA1 | Date |
|---|---|---|
|
|
6546e29ae5 | |
|
|
fb8dc3538b | |
|
|
f7e1cd0b41 |
|
|
@ -0,0 +1,26 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/27 18:56:17 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/27 18:57:25 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
while (*str)
|
||||
write(1, str++, 1);
|
||||
}
|
||||
|
||||
/* ////
|
||||
int main(void)
|
||||
{
|
||||
ft_putstr("HELLO WORLD\n");
|
||||
}
|
||||
*/ ////
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/27 18:57:42 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/27 19:50:56 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
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 main(void)
|
||||
{
|
||||
ft_putnbr(INT_MIN);
|
||||
write(1, "\n", 1);
|
||||
ft_putnbr(-12);
|
||||
write(1, "\n", 1);
|
||||
ft_putnbr(-1);
|
||||
write(1, "\n", 1);
|
||||
ft_putnbr(0);
|
||||
write(1, "\n", 1);
|
||||
ft_putnbr(1);
|
||||
write(1, "\n", 1);
|
||||
ft_putnbr(12);
|
||||
write(1, "\n", 1);
|
||||
ft_putnbr(INT_MAX);
|
||||
write(1, "\n", 1);
|
||||
}
|
||||
*/ ////
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/27 19:51:48 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/28 03:26:16 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_isspace(char c)
|
||||
{
|
||||
return (c == ' '
|
||||
|| c == '\t'
|
||||
|| c == '\n'
|
||||
|| c == '\r'
|
||||
|| c == '\f'
|
||||
|| c == '\v');
|
||||
}
|
||||
|
||||
int ft_atoi(char *str)
|
||||
{
|
||||
while (ft_isspace(*str))
|
||||
++str;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf(": %d\n", ft_atoi(""));
|
||||
printf("0: %d\n", ft_atoi("0"));
|
||||
printf("1: %d\n", ft_atoi("1"));
|
||||
printf("14: %d\n", ft_atoi("14"));
|
||||
printf("120: %d\n", ft_atoi("120"));
|
||||
printf("-0: %d\n", ft_atoi("-0"));
|
||||
printf("-1: %d\n", ft_atoi("-1"));
|
||||
printf("-14: %d\n", ft_atoi("-14"));
|
||||
printf("-120: %d\n", ft_atoi("-120"));
|
||||
printf("2147483647: %d\n", ft_atoi("2147483647"));
|
||||
printf("-2147483648: %d\n", ft_atoi("-2147483648"));
|
||||
}
|
||||
*/ ////
|
||||
Loading…
Reference in New Issue