init
This commit is contained in:
BIN
Correction/lev/ex00/a.out
Executable file
BIN
Correction/lev/ex00/a.out
Executable file
Binary file not shown.
40
Correction/lev/ex00/ft_strcpy.c
Normal file
40
Correction/lev/ex00/ft_strcpy.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/20 16:10:07 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char *ft_strcpy(char *dest, char *src)
|
||||
{
|
||||
while (*src != '\0')
|
||||
{
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
*dest = '\0';
|
||||
return (dest);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char dest[1];
|
||||
char dest1[1];
|
||||
char src[] = "abcde";
|
||||
|
||||
ft_strcpy(dest, src);
|
||||
printf("%s \n\n", dest);
|
||||
strcpy(dest1, src);
|
||||
printf("%s \n\n", dest1);
|
||||
|
||||
return (0);
|
||||
}
|
47
Correction/lev/ex01/ft_strncpy.c
Normal file
47
Correction/lev/ex01/ft_strncpy.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/20 13:25:33 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
i = 0;
|
||||
while (*src != '\0' || i < n)
|
||||
{
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
i++;
|
||||
}
|
||||
return (dest);
|
||||
}
|
||||
|
||||
void ft_print(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
write(1, str++, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int main(void)
|
||||
{
|
||||
char *a;
|
||||
char b[6];
|
||||
|
||||
b[5] = 'd';
|
||||
a = "00000";
|
||||
ft_strncpy(b, a, 5);
|
||||
ft_print(b);
|
||||
}
|
||||
*/
|
24
Correction/lev/ex02/ft_str_is_alpha.c
Normal file
24
Correction/lev/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
Correction/lev/ex03/ft_str_is_numeric.c
Normal file
22
Correction/lev/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
Correction/lev/ex04/ft_str_is_lowercase.c
Normal file
22
Correction/lev/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
Correction/lev/ex05/ft_str_is_uppercase.c
Normal file
22
Correction/lev/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
Correction/lev/ex06/ft_str_is_printable.c
Normal file
22
Correction/lev/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
Correction/lev/ex07/ft_strupcase.c
Normal file
25
Correction/lev/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
Correction/lev/ex08/ft_strlowcase.c
Normal file
25
Correction/lev/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);
|
||||
}
|
72
Correction/lev/ex09/ft_strcapitalize.c
Normal file
72
Correction/lev/ex09/ft_strcapitalize.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcapitalize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:52:54 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/20 13:08:31 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[i] -= 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);
|
||||
}
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char str[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un";
|
||||
printf("%s\n", str);
|
||||
printf("%s", ft_strcapitalize(str));
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user