init
This commit is contained in:
25
C/c02v3/ex00/ft_strcpy.c
Normal file
25
C/c02v3/ex00/ft_strcpy.c
Normal 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/c02v3/ex01/ft_strncpy.c
Normal file
29
C/c02v3/ex01/ft_strncpy.c
Normal 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);
|
||||
}
|
24
C/c02v3/ex02/ft_str_is_alpha.c
Normal file
24
C/c02v3/ex02/ft_str_is_alpha.c
Normal 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);
|
||||
}
|
22
C/c02v3/ex03/ft_str_is_numeric.c
Normal file
22
C/c02v3/ex03/ft_str_is_numeric.c
Normal 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);
|
||||
}
|
22
C/c02v3/ex04/ft_str_is_lowercase.c
Normal file
22
C/c02v3/ex04/ft_str_is_lowercase.c
Normal 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);
|
||||
}
|
22
C/c02v3/ex05/ft_str_is_uppercase.c
Normal file
22
C/c02v3/ex05/ft_str_is_uppercase.c
Normal 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);
|
||||
}
|
22
C/c02v3/ex06/ft_str_is_printable.c
Normal file
22
C/c02v3/ex06/ft_str_is_printable.c
Normal 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);
|
||||
}
|
25
C/c02v3/ex07/ft_strupcase.c
Normal file
25
C/c02v3/ex07/ft_strupcase.c
Normal 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);
|
||||
}
|
25
C/c02v3/ex08/ft_strlowcase.c
Normal file
25
C/c02v3/ex08/ft_strlowcase.c
Normal 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);
|
||||
}
|
61
C/c02v3/ex09/ft_strcapitalize.c
Normal file
61
C/c02v3/ex09/ft_strcapitalize.c
Normal 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);
|
||||
}
|
29
C/c02v3/ex10/ft_strlcpy.c
Normal file
29
C/c02v3/ex10/ft_strlcpy.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/21 14:13:53 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/21 14:18:18 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strlcpy(char *dest, char *src, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (src[i] != '\0' && dest[i] != '\0' && i < n)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
while (i < n && dest[i] != '\0')
|
||||
{
|
||||
dest[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
Reference in New Issue
Block a user