Update Ex6
This commit is contained in:
55
ex0/ft_str_is_alpha.c
Normal file
55
ex0/ft_str_is_alpha.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_str_is_alpha.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 13:14:35 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int ft_str_is_alpha(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_low;
|
||||||
|
int is_up;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_up = (str[i] >= 'a' && str[i] <= 'z');
|
||||||
|
is_low = (str[i] >= 'A' && str[i] <= 'Z');
|
||||||
|
if (!(is_up || is_low))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = "LumiTest123";
|
||||||
|
write(1, "Test avec LumiTest123 : ", 16);
|
||||||
|
ft_putchar(ft_str_is_alpha(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 0 car y'as des chiffres", 32);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
str = "LumiTest";
|
||||||
|
write(1, "Test avec LumiTest : ", 21);
|
||||||
|
ft_putchar(ft_str_is_alpha(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 1 car y'as pas de chiffres", 35);
|
||||||
|
}*/
|
||||||
53
ex1/ft_str_is_numeric.c
Normal file
53
ex1/ft_str_is_numeric.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_str_is_numeric.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 11:31:44 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int ft_str_is_numeric(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_num;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_num = (str[i] >= '0' && str[i] <= '9');
|
||||||
|
if (!(is_num))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = "123";
|
||||||
|
write(1, "Test avec 123 : ", 16);
|
||||||
|
ft_putchar(ft_str_is_numeric(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 1 car y'as des chiffres", 32);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
str = "LumiTest";
|
||||||
|
write(1, "Test avec LumiTest : ", 21);
|
||||||
|
ft_putchar(ft_str_is_numeric(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 0 car y'as pas de chiffres", 35);
|
||||||
|
}*/
|
||||||
40
ex10/ft_putstr_non_printable.c
Normal file
40
ex10/ft_putstr_non_printable.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putstr_non_printable.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 17:05:58 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 17:17:53 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void ft_putstr_non_printable(char *str)
|
||||||
|
{
|
||||||
|
char *base;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
base = "0123456789abcdef";
|
||||||
|
while (str[i])
|
||||||
|
{
|
||||||
|
if (str[i] >= 32 && str[i] <= 126)
|
||||||
|
write(1, &str[i], 1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
write(1, "\\", 1);
|
||||||
|
write(1, &base[(unsigned char)str[i] / 16], 1);
|
||||||
|
write(1, &base[(unsigned char)str[i] % 16], 1);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
ft_putstr_non_printable("Coucou\nLumi\n:3");
|
||||||
|
return (0);
|
||||||
|
}*/
|
||||||
53
ex2/ft_str_is_lowercase.c
Normal file
53
ex2/ft_str_is_lowercase.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_str_is_lowercase.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 13:15:46 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int ft_str_is_lowercase(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_low;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_low = (str[i] >= 'a' && str[i] <= 'z');
|
||||||
|
if (!(is_low))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = "LumiTest123";
|
||||||
|
write(1, "Test avec LumiTest123 : ", 24);
|
||||||
|
ft_putchar(ft_str_is_lowercase(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 0 car y'as des majuscules", 34);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
str = "lumitest";
|
||||||
|
write(1, "Test avec lumitest : ", 21);
|
||||||
|
ft_putchar(ft_str_is_lowercase(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 1 car y'as pas de majuscules", 37);
|
||||||
|
}*/
|
||||||
53
ex3/ft_str_is_uppercase.c
Normal file
53
ex3/ft_str_is_uppercase.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_str_is_uppercase.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 11:43:39 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int ft_str_is_uppercase(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_up;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_up = (str[i] >= 'A' && str[i] <= 'Z');
|
||||||
|
if (!(is_up))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = "LumiTest123";
|
||||||
|
write(1, "Test avec LumiTest123 : ", 24);
|
||||||
|
ft_putchar(ft_str_is_uppercase(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 0 car y'as des minuscules", 34);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
str = "LUMITEST";
|
||||||
|
write(1, "Test avec LUMITEST : ", 21);
|
||||||
|
ft_putchar(ft_str_is_uppercase(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 1 car y'as pas de minuscules", 37);
|
||||||
|
}*/
|
||||||
59
ex4/ft_str_is_printable.c
Normal file
59
ex4/ft_str_is_printable.c
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_str_is_printable.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 12:02:31 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 13:16:41 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int ft_str_is_printable(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_print;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_print = (str[i] >= 32 && str[i] <= 126);
|
||||||
|
if (!(is_print))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = "LumiTest123\n";
|
||||||
|
write(1, "Test avec LumiTest123 (Backslash n) : ", 38);
|
||||||
|
ft_putchar(ft_str_is_printable(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 0 car y'as un non-printable", 36);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
str = "LumiTest123";
|
||||||
|
write(1, "Test avec LumiTest123 : ", 24);
|
||||||
|
ft_putchar(ft_str_is_printable(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 1 car y'as pas de non-printable", 40);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
str = "";
|
||||||
|
write(1, "Test avec Rien (NULL) : ", 24);
|
||||||
|
ft_putchar(ft_str_is_printable(str) + '0');
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Output = 1 car le sujet dis que NULL = 1", 40);
|
||||||
|
}*/
|
||||||
62
ex5/ft_strupcase.c
Normal file
62
ex5/ft_strupcase.c
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strupcase.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 12:39:09 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 13:13:29 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_putstr(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i])
|
||||||
|
{
|
||||||
|
ft_putchar(str[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
char *ft_strupcase(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_low;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_low = (str[i] >= 'a' && str[i] <= 'z');
|
||||||
|
if (is_low)
|
||||||
|
{
|
||||||
|
str[i] = str[i] - 32;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char str[] = "LumiTest123";
|
||||||
|
|
||||||
|
write(1, "Test avec LumiTest123 : ", 24);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Avant : ", 8);
|
||||||
|
ft_putstr(str);
|
||||||
|
ft_strupcase(str);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Apres : ", 8);
|
||||||
|
ft_putstr(str);
|
||||||
|
}*/
|
||||||
62
ex6/ft_strlowcase.c
Normal file
62
ex6/ft_strlowcase.c
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strlowcase.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 12:39:09 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 17:50:21 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_putstr(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i])
|
||||||
|
{
|
||||||
|
ft_putchar(str[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
char *ft_lowcase(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int is_up;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0' )
|
||||||
|
{
|
||||||
|
is_up = (str[i] >= 'A' && str[i] <= 'Z');
|
||||||
|
if (is_up)
|
||||||
|
{
|
||||||
|
str[i] = str[i] + 32;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char str[] = "LumiTest123";
|
||||||
|
|
||||||
|
write(1, "Test avec LumiTest123 : ", 24);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Avant : ", 8);
|
||||||
|
ft_putstr(str);
|
||||||
|
ft_lowcase(str);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Apres : ", 8);
|
||||||
|
ft_putstr(str);
|
||||||
|
}*/
|
||||||
66
ex7/ft_strcapitalize.c
Normal file
66
ex7/ft_strcapitalize.c
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strcapitalize.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 14:30:14 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 16:07:45 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_putstr(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i])
|
||||||
|
{
|
||||||
|
ft_putchar(str[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
char *ft_strcapitalize(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0')
|
||||||
|
{
|
||||||
|
if (str[i] >= 'A' && str[i] <= 'Z')
|
||||||
|
str[i] += 32;
|
||||||
|
if ((str[i] >= 'a' && str[i] <= 'z'))
|
||||||
|
{
|
||||||
|
if (i == 0 || !((str[i - 1] >= 'a' && str[i - 1] <= 'z')
|
||||||
|
|| (str[i - 1] >= 'A' && str[i - 1] <= 'Z')
|
||||||
|
|| (str[i - 1] >= '0' && str[i - 1] <= '9')))
|
||||||
|
{
|
||||||
|
str[i] -= 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char str[] = "salut, ceci-est un+test";
|
||||||
|
|
||||||
|
write(1, "Avant : ", 8);
|
||||||
|
ft_putstr(str);
|
||||||
|
ft_strcapitalize(str);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Apres : ", 8);
|
||||||
|
ft_putstr(str);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
}*/
|
||||||
61
ex8/ft_strlen.c
Normal file
61
ex8/ft_strlen.c
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strlen.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 16:35:32 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 16:57:13 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/*void ft_putnbr(int nb)
|
||||||
|
{
|
||||||
|
char value;
|
||||||
|
|
||||||
|
if (nb == -2147483648)
|
||||||
|
{
|
||||||
|
write(1, "-2147483648", 11);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (nb < 0)
|
||||||
|
{
|
||||||
|
write(1, "-", 1);
|
||||||
|
nb = -nb;
|
||||||
|
}
|
||||||
|
if (nb > 9)
|
||||||
|
{
|
||||||
|
ft_putnbr(nb / 10);
|
||||||
|
}
|
||||||
|
value = nb % 10 + '0';
|
||||||
|
write(1, &value, 1);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int ft_strlen(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i] != '\0')
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
write(1, "Test avec TestLumi : ", 21);
|
||||||
|
len = ft_strlen("TestLumi");
|
||||||
|
ft_putnbr(len);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
write(1, "Test avec Je suis un code C : ", 30);
|
||||||
|
len = ft_strlen("Je suis un code C");
|
||||||
|
ft_putnbr(len);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
}*/
|
||||||
38
ex9/ft_putstr.c
Normal file
38
ex9/ft_putstr.c
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_putstr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/10 14:04:52 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/10 14:21:43 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
void ft_putchar(char chara)
|
||||||
|
{
|
||||||
|
write(1, &chara, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_putstr(char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (str[i])
|
||||||
|
{
|
||||||
|
ft_putchar(str[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int main(void)
|
||||||
|
{
|
||||||
|
char str[] = "Test_Lumi";
|
||||||
|
|
||||||
|
write(1, "Test avec Test_Lumi : ", 24);
|
||||||
|
ft_putstr(str);
|
||||||
|
}*/
|
||||||
Reference in New Issue
Block a user