init
This commit is contained in:
49
C/c02/ex00/ft_strcpy.c
Normal file
49
C/c02/ex00/ft_strcpy.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 12:53:54 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcpy(char *dest, char *src)
|
||||
{
|
||||
while (*src != '\0')
|
||||
{
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
*dest = '\0';
|
||||
return (dest);
|
||||
}
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char dest1[10];
|
||||
char src1[10] = "test";
|
||||
|
||||
strcpy(dest1, src1);
|
||||
|
||||
printf("%s", dest1);
|
||||
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
||||
char dest2[10];
|
||||
char src2[10] = "test";
|
||||
|
||||
ft_strcpy(dest2, src2);
|
||||
|
||||
printf("%s", dest2);
|
||||
}
|
||||
*/
|
53
C/c02/ex01/strncpy.c
Normal file
53
C/c02/ex01/strncpy.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* strncpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/16 15:08:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:05:06 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strncpy(char *dest, char *src, unsigned int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (*src != '\0' && i < n)
|
||||
{
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
i++;
|
||||
}
|
||||
dest[n] = 0;
|
||||
return (dest);
|
||||
}
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char dest1[10];
|
||||
char src1[10] = "test";
|
||||
|
||||
strncpy(dest1, src1, 2);
|
||||
|
||||
printf("%s", dest1);
|
||||
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
||||
char dest2[10];
|
||||
char src2[10] = "test";
|
||||
|
||||
ft_strncpy(dest2, src2, 2);
|
||||
|
||||
printf("%s", dest2);
|
||||
}
|
||||
*/
|
42
C/c02/ex02/ft_str_is_alpha.c
Normal file
42
C/c02/ex02/ft_str_is_alpha.c
Normal file
@ -0,0 +1,42 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_alpha.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/17 13:51:45 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:06:32 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);
|
||||
}
|
||||
|
||||
/*
|
||||
#include <unistd.h>
|
||||
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_putchar(ft_str_is_alpha("ff")+'0');
|
||||
ft_putchar(ft_str_is_alpha("dfdf5f")+'0');
|
||||
ft_putchar(ft_str_is_alpha("GDGFSGF")+48);
|
||||
ft_putchar(ft_str_is_alpha("FG5DG")+48);
|
||||
ft_putchar(ft_str_is_alpha("")+48);
|
||||
}
|
||||
*/
|
37
C/c02/ex03/ft_str_is_numeric.c
Normal file
37
C/c02/ex03/ft_str_is_numeric.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_numeric.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/17 15:29:04 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:08:43 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_numeric(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
if (!((*str >= '0') && (*str <= '9')))
|
||||
return (0);
|
||||
str++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
ft_putchar(ft_str_is_numeric("55654")+48);
|
||||
ft_putchar(ft_str_is_numeric("ssdf5")+48);
|
||||
ft_putchar(ft_str_is_numeric("5")+48);
|
||||
ft_putchar(ft_str_is_numeric("55d654")+48);
|
||||
ft_putchar(ft_str_is_numeric("")+48);
|
||||
}
|
||||
*/
|
37
C/c02/ex04/ft_str_is_lowercase.c
Normal file
37
C/c02/ex04/ft_str_is_lowercase.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_lowercase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/17 13:51:45 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:09:29 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_lowercase(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
if (!('a' <= *str && *str <= 'z'))
|
||||
return (0);
|
||||
str++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
/*
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_putchar(ft_str_is_lowercase("ff")+'0');
|
||||
ft_putchar(ft_str_is_lowercase("dfdf5f")+'0');
|
||||
ft_putchar(ft_str_is_lowercase("d")+48);
|
||||
ft_putchar(ft_str_is_lowercase("FG5DG")+48);
|
||||
ft_putchar(ft_str_is_lowercase("")+48);
|
||||
}
|
||||
*/
|
38
C/c02/ex05/ft_str_is_uppercase.c
Normal file
38
C/c02/ex05/ft_str_is_uppercase.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_uppercase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:46:58 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:10:32 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_uppercase(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
if (!('A' <= *str && *str <= 'Z'))
|
||||
return (0);
|
||||
str++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_putchar(ft_str_is_uppercase("AAA")+'0');
|
||||
ft_putchar(ft_str_is_uppercase("dfdf5f")+'0');
|
||||
ft_putchar(ft_str_is_uppercase("Z")+48);
|
||||
ft_putchar(ft_str_is_uppercase("FG5DG")+48);
|
||||
ft_putchar(ft_str_is_uppercase("")+48);
|
||||
}
|
||||
*/
|
38
C/c02/ex06/ft_str_is_printable.c
Normal file
38
C/c02/ex06/ft_str_is_printable.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_str_is_printable.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 08:36:39 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:11:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_str_is_printable(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
if (!(32 <= *str && *str <= 126))
|
||||
return (0);
|
||||
str++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
void ft_putchar(char c)
|
||||
{
|
||||
write(1, &c, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_putchar(ft_str_is_printable(" ")+48);
|
||||
ft_putchar(ft_str_is_printable("\n")+48);
|
||||
ft_putchar(ft_str_is_printable("~")+48);
|
||||
ft_putchar(ft_str_is_printable("\b")+48);
|
||||
ft_putchar(ft_str_is_printable("")+48);
|
||||
}
|
||||
*/
|
49
C/c02/ex07/ft_strupcase.c
Normal file
49
C/c02/ex07/ft_strupcase.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strupcase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:47:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:11:54 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);
|
||||
}
|
||||
|
||||
/*
|
||||
void ft_print(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
write(1, str++, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char a[4] = "test";
|
||||
ft_print(ft_strupcase(a));
|
||||
|
||||
char b[4] = "TEST";
|
||||
ft_print(ft_strupcase(b));
|
||||
|
||||
char c[4] = "t3st";
|
||||
ft_print(ft_strupcase(c));
|
||||
|
||||
char d[4] = "t3St";
|
||||
ft_print(ft_strupcase(d));
|
||||
|
||||
}
|
||||
*/
|
49
C/c02/ex08/ft_strlowcase.c
Normal file
49
C/c02/ex08/ft_strlowcase.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlowcase.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:47:22 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 13:12:30 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);
|
||||
}
|
||||
|
||||
/*
|
||||
void ft_print(char *str)
|
||||
{
|
||||
while (*str != 0)
|
||||
write(1, str++, 1);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char a[4] = "test";
|
||||
ft_print(ft_strupcase(a));
|
||||
|
||||
char b[4] = "TEST";
|
||||
ft_print(ft_strupcase(b));
|
||||
|
||||
char c[4] = "t3st";
|
||||
ft_print(ft_strupcase(c));
|
||||
|
||||
char d[4] = "t3St";
|
||||
ft_print(ft_strupcase(d));
|
||||
|
||||
}
|
||||
*/
|
51
C/c02/ex09/ft_strcapitalize.c
Normal file
51
C/c02/ex09/ft_strcapitalize.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcapitalize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/18 10:52:54 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/19 12:45:26 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_is_letter(char c)
|
||||
{
|
||||
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
|
||||
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 = 0;
|
||||
while (str[i] != 0)
|
||||
{
|
||||
if (!(ft_is_letter(str[i - 1]) || ft_is_digit(str[i - 1])))
|
||||
if (str[i] >= 'a' && str[i] <= 'z')
|
||||
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", ft_strcapitalize(str));
|
||||
printf("Salut, Comment Tu Vas ? 42mots Quarante-Deux; Cinquante+Et+Un");
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user