Piscine42

This commit is contained in:
2023-12-12 17:25:55 +01:00
commit e07184f084
62 changed files with 1572 additions and 0 deletions

23
C03/ex00/ft_strcmp.c Executable file
View File

@@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 06:53:45 by fgras-ca #+# #+# */
/* Updated: 2022/12/09 08:31:32 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while ((s1[i] == s2[i]) && ((s1[i] != '\0') || (s2[i] != '\0')))
{
i++;
}
return (s1[i] - s2[i]);
}

27
C03/ex01/ft_strncmp.c Executable file
View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 08:08:10 by fgras-ca #+# #+# */
/* Updated: 2022/12/10 13:40:02 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
unsigned int i;
i = 0;
if (n == 0)
{
return (0);
}
while (s1[i] == s2[i] && (s1[i] != '\0' || s2[i] != '\0') && i < (n -1))
{
i++;
}
return (s1[i] - s2[i]);
}

39
C03/ex02/ft_strcat.c Executable file
View File

@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 09:45:42 by fgras-ca #+# #+# */
/* Updated: 2022/12/10 16:13:32 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
{
i++;
}
return (i);
}
char *ft_strcat(char *dest, char *src)
{
int i;
int dest_len;
i = 0;
dest_len = ft_strlen(dest);
while (src[i] != '\0')
{
dest[dest_len + i] = src[i];
i++;
}
dest[dest_len + i] = '\0';
return (dest);
}

39
C03/ex03/ft_strncat.c Executable file
View File

@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/10 16:23:52 by fgras-ca #+# #+# */
/* Updated: 2022/12/12 18:33:50 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
{
i++;
}
return (i);
}
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
unsigned int i;
unsigned int dest_len;
i = 0;
dest_len = ft_strlen(dest);
while (src[i] && i < nb)
{
dest[dest_len + i] = src[i];
i++;
}
dest[dest_len + i] = '\0';
return (dest);
}

BIN
C03/fr.subject.pdf Normal file

Binary file not shown.