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/c03v1/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/c03v1/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/21 12:57:14 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
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/c03v1/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/21 12:59:50 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcat(char *dest, char *src)
{
int i;
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/c03v1/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/21 13:00:52 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
int i;
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);
}

View File

31
C/c03v1/ex04/ft_strstr.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 19:04:42 by cchauvet #+# #+# */
/* Updated: 2022/07/21 13:01:47 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strstr(char *str, char *tofind)
{
int i;
int j;
i = 0;
while (str[i] != 0)
{
j = 0;
while (str[i + j] == tofind[j])
{
if (tofind[j] == 0)
return (&str[i]);
j++;
}
i++;
}
return (0);
}

BIN
C/c03v1/ex05/a.out Executable file

Binary file not shown.

29
C/c03v1/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/21 13:43:41 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
{
int i;
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);
}