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

25
C/c02v4/ex00/ft_strcpy.c Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
/* Updated: 2022/07/21 14:10:25 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strcpy(char *dest, char *src)
{
int i;
i = 0;
while (src[i] != '\0')
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
return (dest);
}

29
C/c02v4/ex01/ft_strncpy.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
/* Updated: 2022/07/21 19:55:13 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = 0;
while (src[i] != '\0' && i < n)
{
dest[i] = src[i];
i++;
}
while (i < n)
{
dest[i] = '\0';
i++;
}
return (dest);
}

View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 13:51:45 by cchauvet #+# #+# */
/* Updated: 2022/07/17 15:22:03 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
while (*str != 0)
{
if (!(('a' <= *str && *str <= 'z') || ('A' <= *str && 'Z' >= *str)))
{
return (0);
}
str++;
}
return (1);
}

View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 15:29:04 by cchauvet #+# #+# */
/* Updated: 2022/07/18 08:43:44 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
while (*str != 0)
{
if (!((*str >= '0') && (*str <= '9')))
return (0);
str++;
}
return (1);
}

View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 13:51:45 by cchauvet #+# #+# */
/* Updated: 2022/07/18 08:36:27 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
while (*str != 0)
{
if (!('a' <= *str && *str <= 'z'))
return (0);
str++;
}
return (1);
}

View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 10:46:58 by cchauvet #+# #+# */
/* Updated: 2022/07/18 10:47:05 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
while (*str != 0)
{
if (!('A' <= *str && *str <= 'Z'))
return (0);
str++;
}
return (1);
}

View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 08:36:39 by cchauvet #+# #+# */
/* Updated: 2022/07/18 08:36:41 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
while (*str != 0)
{
if (!(32 <= *str && *str <= 126))
return (0);
str++;
}
return (1);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strupcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 10:47:22 by cchauvet #+# #+# */
/* Updated: 2022/07/18 10:47:24 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strupcase(char *str)
{
int i;
i = 0;
while (str[i] != 0)
{
if ('a' <= str[i] && str[i] <= 'z')
str[i] = str[i] - 32;
i++;
}
return (str);
}

View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlowcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 10:47:22 by cchauvet #+# #+# */
/* Updated: 2022/07/18 10:49:14 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strlowcase(char *str)
{
int i;
i = 0;
while (str[i] != 0)
{
if ('A' <= str[i] && str[i] <= 'Z')
str[i] = str[i] + 32;
i++;
}
return (str);
}

View File

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 10:52:54 by cchauvet #+# #+# */
/* Updated: 2022/07/22 09:20:34 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
int ft_is_lower(char c)
{
if ('a' <= c && c <= 'z')
return (1);
return (0);
}
int ft_is_upper(char c)
{
if ('A' <= c && c <= 'Z')
return (1);
return (0);
}
int ft_is_alpha(char c)
{
if (ft_is_lower(c) || ft_is_upper(c))
return (1);
return (0);
}
int ft_is_digit(char c)
{
if ('0' <= c && c <= '9')
return (1);
return (0);
}
char *ft_strcapitalize(char *str)
{
int i;
i = 1;
if (ft_is_lower(str[0]))
str[0] -= 32;
while (str[i] != 0)
{
if (!(ft_is_alpha(str[i - 1]) || ft_is_digit(str[i - 1])))
{
if (ft_is_lower(str[i]))
str[i] -= 32;
}
else
if (ft_is_upper(str[i]))
str[i] += 32;
i++;
}
return (str);
}