mirror of
https://github.com/Ladebeze66/Piscine42.git
synced 2026-11-09 13:17:16 +01:00
Piscine42
This commit is contained in:
21
C04/ex00/ft_strlen.c
Executable file
21
C04/ex00/ft_strlen.c
Executable file
@@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/11 13:04:29 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/11 13:06:17 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strlen(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i])
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
25
C04/ex01/ft_putstr.c
Executable file
25
C04/ex01/ft_putstr.c
Executable file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/11 13:08:32 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/13 11:22:07 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
write(1, &str[i], 1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
40
C04/ex02/ft_putnbr.c
Executable file
40
C04/ex02/ft_putnbr.c
Executable file
@@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/11 14:02:07 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/11 17:23:13 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
if (nb == -2147483648)
|
||||
{
|
||||
write(1, "-2147483648", 11);
|
||||
}
|
||||
else if (nb >= 0 && nb < 10)
|
||||
{
|
||||
ft_putchar(nb + 48);
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
ft_putchar('-');
|
||||
ft_putnbr(nb * (-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putnbr (nb / 10);
|
||||
ft_putnbr (nb % 10);
|
||||
}
|
||||
}
|
||||
36
C04/ex03/ft_atoi.c
Executable file
36
C04/ex03/ft_atoi.c
Executable file
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/12/13 10:11:50 by fgras-ca #+# #+# */
|
||||
/* Updated: 2022/12/13 11:01:40 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_atoi(char *str)
|
||||
{
|
||||
int res;
|
||||
int sign;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
res = 0;
|
||||
sign = 1;
|
||||
while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13))
|
||||
i++;
|
||||
while (str[i] == '-' || str[i] == '+')
|
||||
{
|
||||
if (str[i] == '-')
|
||||
sign *= (-1);
|
||||
i++;
|
||||
}
|
||||
while (str[i] >= '0' && str[i] <= '9')
|
||||
{
|
||||
res = res * 10 + str[i] - '0';
|
||||
i++;
|
||||
}
|
||||
return (res * sign);
|
||||
}
|
||||
BIN
C04/fr.subject.pdf
Normal file
BIN
C04/fr.subject.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user