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/titou/ex00/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 12:59:45 by cchauvet #+# #+# */
/* Updated: 2022/07/25 10:37:43 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
while ((*s1 != 0) && (*s2 != 0) && (*s1 == *s2))
{
s1++;
s2++;
}
return (*s1 - *s2);
}
#include <stdio.h>
int main(){
char tab[] = "camille est beau";
char tab2[] = "Camille est beau";
printf("%d", ft_strcmp(tab, tab2));
}

BIN
Correction/titou/ex01/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 13:17:50 by cchauvet #+# #+# */
/* Updated: 2022/07/25 10:39:39 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]);
}
#include <stdio.h>
int main(){
char tab[] = "camille est beau";
char tab2[] = "camille est beau";
printf("%d", ft_strncmp(tab, tab2, 5));
}

BIN
Correction/titou/ex02/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 13:43:42 by cchauvet #+# #+# */
/* Updated: 2022/07/25 10:40:38 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);
}
#include <stdio.h>
int main(){
char tab[] = "camille est beau";
char tab2[] = "Camille est beau";
printf("%s", ft_strcat(tab, tab2));
}

BIN
Correction/titou/ex03/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 19:02:00 by cchauvet #+# #+# */
/* Updated: 2022/07/25 10:43:26 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);
}
#include <stdio.h>
int main(){
char tab[] = "camille est beau";
char tab2[] = "Camille est beau";
printf("%s", ft_strncat(tab, tab2, 10));
}

BIN
Correction/titou/ex04/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 19:04:42 by cchauvet #+# #+# */
/* Updated: 2022/07/25 10:45:52 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);
}
#include <stdio.h>
#include <string.h>
int main (void) {
char haystack1[20] = "TutorialsPointPoint";
char needle1[10] = "Point";
char *ret1;
ret1 = strstr(haystack1, needle1);
printf("The substring is: %s\n", ret1);
printf("\n");
char haystack2[20] = "TutorialsPointPoint";
char needle2[10] = "Point";
char *ret2;
ret2 = ft_strstr(haystack2, needle2);
printf("The substring is: %s\n", ret2);
return(0);
}

View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 13:02:29 by cchauvet #+# #+# */
/* Updated: 2022/07/25 10:49:16 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);
}
#include <stdio.h>
int main()
{
char src[] = "hello";
char dest2[5] = "fjff";
int j;
j = ft_strlcat(src, dest2, 5);
printf("%d %s\n", j, dest2);
}