first commit
This commit is contained in:
25
ended/C02/ex00/ft_strcpy.c
Normal file
25
ended/C02/ex00/ft_strcpy.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 13:14:34 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 13:14:45 by ajoly ### ########.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
ended/C02/ex01/ft_strncpy.c
Normal file
29
ended/C02/ex01/ft_strncpy.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 13:15:09 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 13:15:13 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (i < n && src[i] != '\0')
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
while (i < n)
|
||||
{
|
||||
dest[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
return (dest);
|
||||
}
|
27
ended/C02/ex02/ft_str_is_alpha.c
Normal file
27
ended/C02/ex02/ft_str_is_alpha.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_alpha.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 13:26:15 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 13:26:21 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_alpha(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0' )
|
||||
{
|
||||
if (str[i] < 'A' || (str[i] > 'Z' && str[i] < 'a') || str[i] > 'z')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
27
ended/C02/ex03/ft_str_is_numeric.c
Normal file
27
ended/C02/ex03/ft_str_is_numeric.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_numeric.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 16:54:22 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 16:54:30 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_numeric(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0' )
|
||||
{
|
||||
if (str[i] < '0' || str[i] > '9')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
27
ended/C02/ex04/ft_str_is_lowercase.c
Normal file
27
ended/C02/ex04/ft_str_is_lowercase.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_lowercase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 15:48:34 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 15:48:39 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_lowercase(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0' )
|
||||
{
|
||||
if (str[i] < 'a' || str[i] > 'z')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
27
ended/C02/ex05/ft_str_is_uppercase.c
Normal file
27
ended/C02/ex05/ft_str_is_uppercase.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_uppercase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 16:02:59 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 16:03:03 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_uppercase(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0' )
|
||||
{
|
||||
if (str[i] < 'A' || str[i] > 'Z')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
27
ended/C02/ex06/ft_str_is_printable.c
Normal file
27
ended/C02/ex06/ft_str_is_printable.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_printable.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 16:12:36 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 16:12:40 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_printable(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0' )
|
||||
{
|
||||
if (str[i] < 32 || str[i] > 126)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
27
ended/C02/ex07/ft_strupcase.c
Normal file
27
ended/C02/ex07/ft_strupcase.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strupcase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 16:42:15 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 16:42:19 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strupcase(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
if (str[i] >= 'a' && str[i] <= 'z')
|
||||
{
|
||||
str[i] -= 32;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
27
ended/C02/ex08/ft_strlowcase.c
Normal file
27
ended/C02/ex08/ft_strlowcase.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strupcase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 16:42:15 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 16:42:19 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strlowcase(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
if (str[i] >= 'A' && str[i] <= 'Z')
|
||||
{
|
||||
str[i] += 32;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
40
ended/C02/ex09/ft_strcapitalize.c
Normal file
40
ended/C02/ex09/ft_strcapitalize.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcapitalize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/19 19:09:13 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/19 19:09:17 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcapitalize(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
if (str[i] >= 'a' && str[i] <= 'z')
|
||||
{
|
||||
if (str[i - 1] <= 47 || str[i - 1] == 0
|
||||
|| (str[i - 1] >= 58 && str[i - 1] <= 64)
|
||||
|| (str[i - 1] >= 91 && str[i - 1] <= 96)
|
||||
|| (str[i - 1] >= 123 && str[i - 1] <= 126))
|
||||
{
|
||||
str[i] -= 32;
|
||||
}
|
||||
}
|
||||
if (str[i] >= 'A' && str[i] <= 'Z')
|
||||
{
|
||||
if (str[i - 1] > 47)
|
||||
{
|
||||
str[i] += 32;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
30
ended/C02/ex10/ft_strlcpy.c
Normal file
30
ended/C02/ex10/ft_strlcpy.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ajoly <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/20 08:23:38 by ajoly #+# #+# */
|
||||
/* Updated: 2022/07/20 08:23:41 by ajoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
if (size > 0)
|
||||
{
|
||||
while (--size && src[i])
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
dest[i] = '\0';
|
||||
}
|
||||
while (src[i])
|
||||
i++;
|
||||
return (i);
|
||||
}
|
Reference in New Issue
Block a user