Add all git folders
This commit is contained in:
7
C_Piscine_C_04/git/.gitignore
vendored
Normal file
7
C_Piscine_C_04/git/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
**/main.c
|
||||
**/main.sh
|
||||
**/a.out
|
||||
**/a.sh
|
||||
**/Makefile
|
||||
**/*.swp
|
||||
**/*~
|
||||
21
C_Piscine_C_04/git/ex00/ft_strlen.c
Normal file
21
C_Piscine_C_04/git/ex00/ft_strlen.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/13 09:03:26 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/13 09:09:57 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strlen(char *str)
|
||||
{
|
||||
char *p_str;
|
||||
|
||||
p_str = str;
|
||||
while (*p_str != '\0')
|
||||
p_str++;
|
||||
return (p_str - str);
|
||||
}
|
||||
22
C_Piscine_C_04/git/ex01/ft_putstr.c
Normal file
22
C_Piscine_C_04/git/ex01/ft_putstr.c
Normal file
@@ -0,0 +1,22 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/13 09:16:54 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/13 09:21:15 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putstr(char *str)
|
||||
{
|
||||
char *p_str;
|
||||
|
||||
p_str = str;
|
||||
while (*p_str != '\0')
|
||||
write(1, p_str++, 1);
|
||||
}
|
||||
38
C_Piscine_C_04/git/ex02/ft_putnbr.c
Normal file
38
C_Piscine_C_04/git/ex02/ft_putnbr.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_putnbr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/13 09:24:02 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/13 14:47:24 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putnbr(int nb)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (nb == -2147483648)
|
||||
write(1, "-2147483648", 11);
|
||||
else if (nb >= 10)
|
||||
{
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(nb % 10);
|
||||
}
|
||||
else if (nb < 0)
|
||||
{
|
||||
write(1, "-", 1);
|
||||
nb *= -1;
|
||||
ft_putnbr(nb / 10);
|
||||
ft_putnbr(nb % 10);
|
||||
}
|
||||
else if (nb >= 0)
|
||||
{
|
||||
c = nb + '0';
|
||||
write(1, &c, 1);
|
||||
}
|
||||
}
|
||||
39
C_Piscine_C_04/git/ex03/ft_atoi.c
Normal file
39
C_Piscine_C_04/git/ex03/ft_atoi.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/13 12:46:22 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/13 14:58:30 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_atoi(char *str)
|
||||
{
|
||||
int nb;
|
||||
int s;
|
||||
int i;
|
||||
|
||||
nb = 0;
|
||||
s = 0;
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
if (str[i] == ' ' || (str[i] >= '\t' && str[i] <= '\r'))
|
||||
s += 0;
|
||||
else if (str[i] == '+')
|
||||
s++;
|
||||
else if (str[i] == '-')
|
||||
s--;
|
||||
else if (str[i] >= '0' && str[i] <= '9')
|
||||
nb = nb * 10 + str[i] - '0';
|
||||
else
|
||||
break ;
|
||||
i++;
|
||||
}
|
||||
if (s < 0)
|
||||
nb *= -1;
|
||||
return (nb);
|
||||
}
|
||||
Reference in New Issue
Block a user