Add all git folders
This commit is contained in:
7
C_Piscine_C_03/git/.gitignore
vendored
Normal file
7
C_Piscine_C_03/git/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
**/main.c
|
||||
**/main.sh
|
||||
**/a.out
|
||||
**/a.sh
|
||||
**/Makefile
|
||||
**/*.swp
|
||||
**/*~
|
||||
28
C_Piscine_C_03/git/ex00/ft_strcmp.c
Normal file
28
C_Piscine_C_03/git/ex00/ft_strcmp.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/12 12:14:57 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 14:50:37 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strcmp(char *s1, char *s2)
|
||||
{
|
||||
char c1;
|
||||
char c2;
|
||||
|
||||
c1 = '\0';
|
||||
c2 = '\0';
|
||||
while (c1 == c2)
|
||||
{
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
if (c1 == '\0')
|
||||
break ;
|
||||
}
|
||||
return (c1 - c2);
|
||||
}
|
||||
31
C_Piscine_C_03/git/ex01/ft_strncmp.c
Normal file
31
C_Piscine_C_03/git/ex01/ft_strncmp.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/12 15:16:07 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 15:16:11 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||
{
|
||||
char c1;
|
||||
char c2;
|
||||
|
||||
if (n == 0)
|
||||
return (0);
|
||||
c1 = '\0';
|
||||
c2 = '\0';
|
||||
while (n > 0)
|
||||
{
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
if (c1 == '\0' || c1 != c2)
|
||||
break ;
|
||||
n--;
|
||||
}
|
||||
return (c1 - c2);
|
||||
}
|
||||
26
C_Piscine_C_03/git/ex02/ft_strcat.c
Normal file
26
C_Piscine_C_03/git/ex02/ft_strcat.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/12 16:01:50 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 16:37:01 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcat(char *dest, char *src)
|
||||
{
|
||||
char *s1;
|
||||
char *s2;
|
||||
|
||||
s1 = dest;
|
||||
s2 = src;
|
||||
while (*s1 != '\0')
|
||||
s1++;
|
||||
while (*s2 != '\0')
|
||||
*s1++ = *s2++;
|
||||
*s1 = '\0';
|
||||
return (dest);
|
||||
}
|
||||
29
C_Piscine_C_03/git/ex03/ft_strncat.c
Normal file
29
C_Piscine_C_03/git/ex03/ft_strncat.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/12 16:43:59 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 16:47:35 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strncat(char *dest, char *src, unsigned int nb)
|
||||
{
|
||||
char *s1;
|
||||
char *s2;
|
||||
|
||||
s1 = dest;
|
||||
s2 = src;
|
||||
while (*s1 != '\0')
|
||||
s1++;
|
||||
while (nb > 0 && *s2 != '\0')
|
||||
{
|
||||
*s1++ = *s2++;
|
||||
nb--;
|
||||
}
|
||||
*s1 = '\0';
|
||||
return (dest);
|
||||
}
|
||||
31
C_Piscine_C_03/git/ex04/ft_strstr.c
Normal file
31
C_Piscine_C_03/git/ex04/ft_strstr.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/12 16:49:31 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 17:11:14 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
char *ft_strstr(char *str, char *to_find)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
j = 0;
|
||||
while (str[i + j] != '\0' && str[i + j] == to_find[j])
|
||||
j++;
|
||||
if (to_find[j] == '\0')
|
||||
return (str + i);
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
36
C_Piscine_C_03/git/ex05/ft_strlcat.c
Normal file
36
C_Piscine_C_03/git/ex05/ft_strlcat.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/12 17:12:30 by gbaconni #+# #+# */
|
||||
/* Updated: 2021/08/12 17:48:17 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
|
||||
{
|
||||
char *s1;
|
||||
char *s2;
|
||||
unsigned int size_dest;
|
||||
|
||||
s1 = dest;
|
||||
s2 = src;
|
||||
size_dest = 0;
|
||||
while (*s1 != '\0')
|
||||
s1++;
|
||||
size_dest = s1 - dest;
|
||||
while (*s2 != '\0')
|
||||
{
|
||||
if (size != 1)
|
||||
{
|
||||
*s1++ = *s2++;
|
||||
size--;
|
||||
}
|
||||
s2++;
|
||||
}
|
||||
*s1 = '\0';
|
||||
return (size_dest + (s2 - src));
|
||||
}
|
||||
Reference in New Issue
Block a user