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

BIN
Correction/dfdgdf/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/20 13:44:45 by jmendez #+# #+# */
/* Updated: 2022/07/20 14:29:30 by jmendez ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] == s2[i] && (s1[i] && s2[i]))
i ++;
return (s1[i] - s2[i]);
}

View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/20 14:58:04 by jmendez #+# #+# */
/* Updated: 2022/07/20 15:00:50 by jmendez ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
unsigned int i;
i = 0;
while (i < n)
{
if (s1[i] != s2[i] || s1[i] == '\0' || s2[i] == '\0')
{
return (s1[i] - s2[i]);
}
i++;
}
return (0);
}

View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/20 20:57:39 by jmendez #+# #+# */
/* Updated: 2022/07/20 22:44:31 by jmendez ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcat(char *dest, char *src)
{
int i;
int j;
i = 0;
j = 0;
while (dest[i] != '\0')
i++;
while (src[j] != '\0')
{
dest[i] = src[j];
i++;
j++;
}
dest[i] = '\0';
return (dest);
}

View File

@ -0,0 +1,43 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/20 22:47:28 by jmendez #+# #+# */
/* Updated: 2022/07/25 16:53:34 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncat(char *dest, char *src, unsigned int nb)
{
int i;
unsigned int j;
i = 0;
j = 0;
while (dest[i] != '\0')
i++;
while (j < nb)
{
dest[i] = src[j];
i++;
j++;
}
return (dest);
}
#include <string.h>
#include <stdio.h>
int main()
{
char a[] = "sss";
char b[] = "aaa";
char c[] = "aaa";
printf("%s", strncat(b, a, 5));
printf("\n%s", ft_strncat(c, a, 5));
}

View File

@ -0,0 +1,70 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 12:35:36 by jmendez #+# #+# */
/* Updated: 2022/07/25 16:56:29 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
char *ft_strstr(char *str, char *to_find)
{
int i;
int j;
i = 0;
j = 0;
if (to_find[j] == '\0')
return (str);
while (str[i] != '\0')
{
if (str[i] == to_find[j])
{
while (str[i] == to_find[j])
{
i++;
j++;
if (to_find[j] == '\0')
return (&str[i - j]);
}
i = i - j;
}
j = 0;
i++;
}
return (NULL);
}
#include <stdio.h>
#include <string.h>
int main (void) {
char haystack1[20] = "TutorialsPoint";
char needle1[10] = "Pint";
char *ret1;
ret1 = strstr(haystack1, needle1);
printf("The substring is: %s\n", ret1);
printf("\n");
char haystack2[20] = "TutorialsPoint";
char needle2[10] = "Pint";
char *ret2;
ret2 = ft_strstr(haystack2, needle2);
printf("The substring is: %s\n", ret2);
return(0);
}

View File

@ -0,0 +1,57 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jmendez <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 17:13:43 by jmendez #+# #+# */
/* Updated: 2022/07/25 17:00:32 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
int howmuch;
howmuch = 0;
while (*str++)
howmuch++;
return (howmuch);
}
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
unsigned int i;
i = -1;
while (++i < size - 1 && src[i])
dest[i] = src[i];
dest[i + 1] = '\0';
return (i);
}
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
{
unsigned int length;
length = ft_strlen(dest);
if (length >= size)
length = size;
if (length == size)
return (length + ft_strlen(src));
return (length + ft_strlcpy(dest + length, src, size - length));
}
#include <stdio.h>
int main()
{
char src[] = "hello";
char dest2[10] = "fjff";
int j;
j = ft_strlcat(dest2, src, 7);
printf("%d %s\n", j, dest2);
}