This commit is contained in:
Camille Chauvet
2023-05-17 16:45:25 +00:00
commit 29ed24d567
619 changed files with 16119 additions and 0 deletions

21
C/c03v2/ex00/ft_strcmp.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 12:59:45 by cchauvet #+# #+# */
/* Updated: 2022/07/21 13:40:07 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
while ((*s1 != 0) && (*s2 != 0) && (*s1 == *s2))
{
s1++;
s2++;
}
return (*s1 - *s2);
}

21
C/c03v2/ex01/ft_strncmp.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 13:17:50 by cchauvet #+# #+# */
/* Updated: 2022/07/24 17:41:37 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
unsigned int i;
i = 0;
while (s1[i] != 0 && s2[i] != 0 && s1[i] == s2[i] && i < n - 1)
i++;
return (s1[i] - s2[i]);
}

29
C/c03v2/ex02/ft_strcat.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 13:43:42 by cchauvet #+# #+# */
/* Updated: 2022/07/24 17:42:30 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcat(char *dest, char *src)
{
unsigned int i;
unsigned int j;
i = 0;
while (dest[i] != 0)
i++;
j = 0;
while (src[j] != 0)
{
dest[i + j] = src[j];
j++;
}
dest[i + j] = 0;
return (dest);
}

29
C/c03v2/ex03/ft_strncat.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 19:02:00 by cchauvet #+# #+# */
/* Updated: 2022/07/24 17:42:52 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
unsigned int i;
unsigned int j;
i = 0;
while (dest[i] != 0)
i++;
j = 0;
while (src[j] != 0 && j < nb)
{
dest[i + j] = src[j];
j++;
}
dest[i + j] = 0;
return (dest);
}

33
C/c03v2/ex04/ft_strstr.c Normal file
View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 19:04:42 by cchauvet #+# #+# */
/* Updated: 2022/07/24 17:43:35 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strstr(char *str, char *to_find)
{
unsigned int i;
unsigned int j;
i = 0;
if (to_find[0] == '\0')
return (str);
while (str[i] != 0)
{
j = 0;
while (str[i + j] == to_find[j])
{
if (to_find[j + 1] == 0)
return (&str[i]);
j++;
}
i++;
}
return (0);
}

29
C/c03v2/ex05/ft_strlcat.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 13:02:29 by cchauvet #+# #+# */
/* Updated: 2022/07/24 17:43:54 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
{
unsigned int i;
unsigned int j;
i = 0;
while (dest[i] != 0)
i++;
j = 0;
while (src[j] != 0 && i < size)
{
dest[i + j] = src[j];
j++;
}
dest[i + j] = '\0';
return (j + i);
}