From 3b8d303f774e395a65db23a62dbf54ad900fc7bf Mon Sep 17 00:00:00 2001 From: lclerel- lclerel- Date: Mon, 23 Mar 2026 14:47:43 +0100 Subject: [PATCH] Update Final 42 --- .../C-Algorithmics-Fundamentals | 1 - .../ex0/ft_iterative_factorial.c | 86 ++++++++ .../ex1/ft_recursive_factorial.c | 77 +++++++ .../ex2/ft_iterative_power.c | 80 +++++++ .../ex3/ft_recursive_power.c | 72 +++++++ .../ex4/ft_fibonacci.c | 72 +++++++ .../C-Characters-Arithmetics | 1 - .../C-Characters-Arithmetics/ex0/ft_putnbr.c | 42 ++++ .../ex1/ft_print_comb.c | 52 +++++ .../ex2/ft_print_comb2.c | 50 +++++ .../ex3/ft_print_combn.c | 72 +++++++ .../C-Programming-Fundamentals | 1 - .../ex0/ft_putchar.c | 18 ++ .../ex1/ft_print_alphabet.c | 18 ++ .../ex2/ft_print_reverse_alphabet.c | 18 ++ .../ex3/ft_print_numbers.c | 18 ++ .../ex4/ft_is_negative.c | 28 +++ Memory Management/C-Function-Pointers | 1 - .../C-Function-Pointers/ex0/ft_foreach.c | 66 ++++++ .../C-Function-Pointers/ex1/ft_map.c | 80 +++++++ .../C-Function-Pointers/ex2/ft_any.c | 58 +++++ .../C-Function-Pointers/ex3/ft_count_if.c | 96 +++++++++ .../C-Function-Pointers/ex4/ft_is_sort.c | 105 +++++++++ Memory Management/C-Memory-Management | 1 - .../C-Memory-Management/ex0/ft_strdup.c | 71 +++++++ .../C-Memory-Management/ex1/ft_range.c | 116 ++++++++++ .../ex2/ft_ultimate_range.c | 125 +++++++++++ .../C-Memory-Management/ex3/ft_strjoin.c | 133 ++++++++++++ .../C-Memory-Management/ex4/ft_convert_base.c | 200 ++++++++++++++++++ .../ex4/ft_convert_base2.c | 82 +++++++ .../C-Memory-Management/ex5/ft_split.c | 117 ++++++++++ Memory Management/C-Pointers | 1 - Memory Management/C-Pointers/ex0/ft_ft.c | 58 +++++ .../C-Pointers/ex1/ft_ultimate_ft.c | 74 +++++++ Memory Management/C-Pointers/ex2/ft_swap.c | 68 ++++++ Memory Management/C-Pointers/ex3/ft_div_mod.c | 62 ++++++ .../C-Pointers/ex4/ft_ultimate_div_mod.c | 68 ++++++ .../C-Pointers/ex5/ft_rev_int_tab.c | 76 +++++++ .../C-Pointers/ex6/ft_sort_int_tab.c | 87 ++++++++ Memory Management/C-Simple-Strings | 1 - .../C-Simple-Strings/ex0/#ft_str_is_alpha.c# | 55 +++++ .../C-Simple-Strings/ex0/ft_str_is_alpha.c | 55 +++++ .../C-Simple-Strings/ex1/ft_str_is_numeric.c | 53 +++++ .../ex10/ft_putstr_non_printable.c | 40 ++++ .../ex2/ft_str_is_lowercase.c | 53 +++++ .../ex3/ft_str_is_uppercase.c | 53 +++++ .../ex4/ft_str_is_printable.c | 59 ++++++ .../C-Simple-Strings/ex5/ft_strupcase.c | 62 ++++++ .../C-Simple-Strings/ex6/ft_strlowcase.c | 62 ++++++ .../C-Simple-Strings/ex7/ft_strcapitalize.c | 66 ++++++ .../C-Simple-Strings/ex8/ft_strlen.c | 61 ++++++ .../C-Simple-Strings/ex9/ft_putstr.c | 38 ++++ Memory Management/C-System-Interface | 1 - .../ex0/ft_print_program_name.c | 25 +++ .../C-System-Interface/ex1/ft_print_params.c | 32 +++ .../C-System-Interface/ex2/ft_rev_params.c | 32 +++ .../C-System-Interface/ex3/ft_sort_params.c | 68 ++++++ Shell/Git-Fundamentals | 1 - Shell/Git-Fundamentals/ex0/git_commit.sh | 1 + Shell/Git-Fundamentals/ex1/git_ignore.sh | 1 + Shell/Shell-Fundamentals | 1 - Shell/Shell-Fundamentals/ex0/testShell00.tar | Bin 0 -> 10240 bytes Shell/Shell-Fundamentals/ex1/ex1.tar | Bin 0 -> 10240 bytes Shell/Shell-Fundamentals/ex2/midLS | 1 + .../ex3/\"\\?$*'MaRViN'*$?\\\"" | 1 + Shell/Shell-Searching-And-Finding | 1 - .../ex0/find_sh.sh | 1 + Shell/Shell-Searching-And-Finding/ex1/clean | 1 + .../ex2/count_files.sh | 1 + Tutorial/C-Project-Tutorial | 1 - Tutorial/C-Project-Tutorial/ex0/z | 1 + Tutorial/C-Project-Tutorial/ex1/id_rsa_pub | 1 + 72 files changed, 3268 insertions(+), 12 deletions(-) delete mode 160000 Imperative Programming/C-Algorithmics-Fundamentals create mode 100644 Imperative Programming/C-Algorithmics-Fundamentals/ex0/ft_iterative_factorial.c create mode 100644 Imperative Programming/C-Algorithmics-Fundamentals/ex1/ft_recursive_factorial.c create mode 100644 Imperative Programming/C-Algorithmics-Fundamentals/ex2/ft_iterative_power.c create mode 100644 Imperative Programming/C-Algorithmics-Fundamentals/ex3/ft_recursive_power.c create mode 100644 Imperative Programming/C-Algorithmics-Fundamentals/ex4/ft_fibonacci.c delete mode 160000 Imperative Programming/C-Characters-Arithmetics create mode 100644 Imperative Programming/C-Characters-Arithmetics/ex0/ft_putnbr.c create mode 100644 Imperative Programming/C-Characters-Arithmetics/ex1/ft_print_comb.c create mode 100644 Imperative Programming/C-Characters-Arithmetics/ex2/ft_print_comb2.c create mode 100644 Imperative Programming/C-Characters-Arithmetics/ex3/ft_print_combn.c delete mode 160000 Imperative Programming/C-Programming-Fundamentals create mode 100644 Imperative Programming/C-Programming-Fundamentals/ex0/ft_putchar.c create mode 100644 Imperative Programming/C-Programming-Fundamentals/ex1/ft_print_alphabet.c create mode 100644 Imperative Programming/C-Programming-Fundamentals/ex2/ft_print_reverse_alphabet.c create mode 100644 Imperative Programming/C-Programming-Fundamentals/ex3/ft_print_numbers.c create mode 100644 Imperative Programming/C-Programming-Fundamentals/ex4/ft_is_negative.c delete mode 160000 Memory Management/C-Function-Pointers create mode 100644 Memory Management/C-Function-Pointers/ex0/ft_foreach.c create mode 100644 Memory Management/C-Function-Pointers/ex1/ft_map.c create mode 100644 Memory Management/C-Function-Pointers/ex2/ft_any.c create mode 100644 Memory Management/C-Function-Pointers/ex3/ft_count_if.c create mode 100644 Memory Management/C-Function-Pointers/ex4/ft_is_sort.c delete mode 160000 Memory Management/C-Memory-Management create mode 100644 Memory Management/C-Memory-Management/ex0/ft_strdup.c create mode 100644 Memory Management/C-Memory-Management/ex1/ft_range.c create mode 100644 Memory Management/C-Memory-Management/ex2/ft_ultimate_range.c create mode 100644 Memory Management/C-Memory-Management/ex3/ft_strjoin.c create mode 100644 Memory Management/C-Memory-Management/ex4/ft_convert_base.c create mode 100644 Memory Management/C-Memory-Management/ex4/ft_convert_base2.c create mode 100644 Memory Management/C-Memory-Management/ex5/ft_split.c delete mode 160000 Memory Management/C-Pointers create mode 100644 Memory Management/C-Pointers/ex0/ft_ft.c create mode 100644 Memory Management/C-Pointers/ex1/ft_ultimate_ft.c create mode 100644 Memory Management/C-Pointers/ex2/ft_swap.c create mode 100644 Memory Management/C-Pointers/ex3/ft_div_mod.c create mode 100644 Memory Management/C-Pointers/ex4/ft_ultimate_div_mod.c create mode 100644 Memory Management/C-Pointers/ex5/ft_rev_int_tab.c create mode 100644 Memory Management/C-Pointers/ex6/ft_sort_int_tab.c delete mode 160000 Memory Management/C-Simple-Strings create mode 100644 Memory Management/C-Simple-Strings/ex0/#ft_str_is_alpha.c# create mode 100644 Memory Management/C-Simple-Strings/ex0/ft_str_is_alpha.c create mode 100644 Memory Management/C-Simple-Strings/ex1/ft_str_is_numeric.c create mode 100644 Memory Management/C-Simple-Strings/ex10/ft_putstr_non_printable.c create mode 100644 Memory Management/C-Simple-Strings/ex2/ft_str_is_lowercase.c create mode 100644 Memory Management/C-Simple-Strings/ex3/ft_str_is_uppercase.c create mode 100644 Memory Management/C-Simple-Strings/ex4/ft_str_is_printable.c create mode 100644 Memory Management/C-Simple-Strings/ex5/ft_strupcase.c create mode 100644 Memory Management/C-Simple-Strings/ex6/ft_strlowcase.c create mode 100644 Memory Management/C-Simple-Strings/ex7/ft_strcapitalize.c create mode 100644 Memory Management/C-Simple-Strings/ex8/ft_strlen.c create mode 100644 Memory Management/C-Simple-Strings/ex9/ft_putstr.c delete mode 160000 Memory Management/C-System-Interface create mode 100644 Memory Management/C-System-Interface/ex0/ft_print_program_name.c create mode 100644 Memory Management/C-System-Interface/ex1/ft_print_params.c create mode 100644 Memory Management/C-System-Interface/ex2/ft_rev_params.c create mode 100644 Memory Management/C-System-Interface/ex3/ft_sort_params.c delete mode 160000 Shell/Git-Fundamentals create mode 100644 Shell/Git-Fundamentals/ex0/git_commit.sh create mode 100644 Shell/Git-Fundamentals/ex1/git_ignore.sh delete mode 160000 Shell/Shell-Fundamentals create mode 100644 Shell/Shell-Fundamentals/ex0/testShell00.tar create mode 100644 Shell/Shell-Fundamentals/ex1/ex1.tar create mode 100644 Shell/Shell-Fundamentals/ex2/midLS create mode 100644 "Shell/Shell-Fundamentals/ex3/\"\\?$*'MaRViN'*$?\\\"" delete mode 160000 Shell/Shell-Searching-And-Finding create mode 100755 Shell/Shell-Searching-And-Finding/ex0/find_sh.sh create mode 100755 Shell/Shell-Searching-And-Finding/ex1/clean create mode 100755 Shell/Shell-Searching-And-Finding/ex2/count_files.sh delete mode 160000 Tutorial/C-Project-Tutorial create mode 100644 Tutorial/C-Project-Tutorial/ex0/z create mode 100644 Tutorial/C-Project-Tutorial/ex1/id_rsa_pub diff --git a/Imperative Programming/C-Algorithmics-Fundamentals b/Imperative Programming/C-Algorithmics-Fundamentals deleted file mode 160000 index 4d55e3b..0000000 --- a/Imperative Programming/C-Algorithmics-Fundamentals +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4d55e3b2c16c25725750a842eac77ee851240c3e diff --git a/Imperative Programming/C-Algorithmics-Fundamentals/ex0/ft_iterative_factorial.c b/Imperative Programming/C-Algorithmics-Fundamentals/ex0/ft_iterative_factorial.c new file mode 100644 index 0000000..d16c10e --- /dev/null +++ b/Imperative Programming/C-Algorithmics-Fundamentals/ex0/ft_iterative_factorial.c @@ -0,0 +1,86 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iterative_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 10:08:57 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 13:07:20 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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_iterative_factorial(int nb) +{ + int res; + + res = 1; + if (nb < 0) + return (0); + if (nb == 0 || nb == 1) + return (1); + while (nb > 1) + { + res = res * nb; + nb--; + } + return (res); +} + +/*int main(void) +{ + int nb; + + write(1, "Test avec factoriel de 5:", 25); + write(1, "\n", 1); + nb = ft_iterative_factorial(5); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec factoriel de 10:", 26); + write(1, "\n", 1); + nb = ft_iterative_factorial(10); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec factoriel de 20:", 26); + write(1, "\n", 1); + nb = ft_iterative_factorial(20); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "(20 depasse l'int limit, resultat negatif)", 42); + write(1, "\n", 1); + write(1, "Test avec factoriel de 0:", 25); + write(1, "\n", 1); + nb = ft_iterative_factorial(0); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec aucune factoriel:", 27); + write(1, "\n", 1); + nb = ft_iterative_factorial(-14); + ft_putnbr(nb); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Imperative Programming/C-Algorithmics-Fundamentals/ex1/ft_recursive_factorial.c b/Imperative Programming/C-Algorithmics-Fundamentals/ex1/ft_recursive_factorial.c new file mode 100644 index 0000000..9330cd6 --- /dev/null +++ b/Imperative Programming/C-Algorithmics-Fundamentals/ex1/ft_recursive_factorial.c @@ -0,0 +1,77 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 09:57:06 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 13:09:08 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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'; +}*/ + +int ft_recursive_factorial(int nb) +{ + if (nb < 0) + return (0); + if (nb == 0 || nb == 1) + return (1); + return (nb * ft_recursive_factorial(nb -1)); +} + +/*int main(void) +{ + int nb; + + write(1, "Test avec factoriel de 5:", 25); + write(1, "\n", 1); + nb = ft_recursive_factorial(5); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec factoriel de 10:", 26); + write(1, "\n", 1); + nb = ft_recursive_factorial(10); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec factoriel de 20:", 26); + write(1, "\n", 1); + nb = ft_recursive_factorial(20); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "(20 depasse l'int limit, resultat negatif)", 42); + write(1, "\n", 1); + write(1, "Test avec factoriel de 0:", 25); + write(1, "\n", 1); + nb = ft_recursive_factorial(0); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec aucune factoriel:", 27); + write(1, "\n", 1); + nb = ft_recursive_factorial(-14); + ft_putnbr(nb); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Imperative Programming/C-Algorithmics-Fundamentals/ex2/ft_iterative_power.c b/Imperative Programming/C-Algorithmics-Fundamentals/ex2/ft_iterative_power.c new file mode 100644 index 0000000..e9118c4 --- /dev/null +++ b/Imperative Programming/C-Algorithmics-Fundamentals/ex2/ft_iterative_power.c @@ -0,0 +1,80 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iterative_power.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 10:22:48 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 13:09:15 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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'; +}*/ + +int ft_iterative_power(int nb, int power) +{ + int res; + + res = 1; + if (power < 0) + return (0); + if (power == 0) + return (1); + while (power > 0) + { + res = res * nb; + power--; + } + return (res); +} + +/*int main(void) +{ + int nb; + + write(1, "Test avec puissance de 5:", 25); + write(1, "\n", 1); + nb = ft_iterative_power(5, 5); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec puissance de 10:", 26); + write(1, "\n", 1); + nb = ft_iterative_power(10, 10); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec puissance de 20:", 26); + write(1, "\n", 1); + nb = ft_iterative_power(20, 20); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "(20 depasse l'int limit, resultat mis a 0)", 42); + write(1, "\n", 1); + write(1, "Test avec puissance de 0:", 25); + write(1, "\n", 1); + nb = ft_iterative_power(0, 0); + ft_putnbr(nb); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Imperative Programming/C-Algorithmics-Fundamentals/ex3/ft_recursive_power.c b/Imperative Programming/C-Algorithmics-Fundamentals/ex3/ft_recursive_power.c new file mode 100644 index 0000000..2792cdc --- /dev/null +++ b/Imperative Programming/C-Algorithmics-Fundamentals/ex3/ft_recursive_power.c @@ -0,0 +1,72 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_power.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 10:34:20 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 13:09:22 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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'; +}*/ + +int ft_recursive_power(int nb, int power) +{ + if (power < 0) + return (0); + if (power == 0) + return (1); + return (nb * ft_recursive_power(nb, power -1)); +} + +int main(void) +{ + int nb; + + write(1, "Test avec puissance de 5:", 25); + write(1, "\n", 1); + nb = ft_recursive_power(5, 5); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec puissance de 10:", 26); + write(1, "\n", 1); + nb = ft_recursive_power(10, 10); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec puissance de 20:", 26); + write(1, "\n", 1); + nb = ft_recursive_power(20, 20); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "(20 depasse l'int limit, resultat mis a 0)", 42); + write(1, "\n", 1); + write(1, "Test avec puissance de 0:", 25); + write(1, "\n", 1); + nb = ft_recursive_power(0, 0); + ft_putnbr(nb); + write(1, "\n", 1); + return (0); +} diff --git a/Imperative Programming/C-Algorithmics-Fundamentals/ex4/ft_fibonacci.c b/Imperative Programming/C-Algorithmics-Fundamentals/ex4/ft_fibonacci.c new file mode 100644 index 0000000..88c3165 --- /dev/null +++ b/Imperative Programming/C-Algorithmics-Fundamentals/ex4/ft_fibonacci.c @@ -0,0 +1,72 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_fibonacci.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 10:48:57 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 13:09:29 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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'; +}*/ + +int ft_fibonacci(int index) +{ + if (index < 0) + return (-1); + if (index == 0) + return (0); + if (index == 1) + return (1); + return (ft_fibonacci(index - 1) + ft_fibonacci(index - 2)); +} + +/*int main(void) +{ + int nb; + + write(1, "Test avec index de 5:", 22); + write(1, "\n", 1); + nb = ft_fibonacci(5); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec index de 10:", 23); + write(1, "\n", 1); + nb = ft_fibonacci(10); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec index de -1:", 23); + write(1, "\n", 1); + nb = ft_fibonacci(-1); + ft_putnbr(nb); + write(1, "\n", 1); + write(1, "Test avec index de 30:", 23); + write(1, "\n", 1); + nb = ft_fibonacci(30); + ft_putnbr(nb); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Imperative Programming/C-Characters-Arithmetics b/Imperative Programming/C-Characters-Arithmetics deleted file mode 160000 index 2ced9ae..0000000 --- a/Imperative Programming/C-Characters-Arithmetics +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2ced9aed8d25daefd264891007092e2000bcf5e7 diff --git a/Imperative Programming/C-Characters-Arithmetics/ex0/ft_putnbr.c b/Imperative Programming/C-Characters-Arithmetics/ex0/ft_putnbr.c new file mode 100644 index 0000000..f886dbd --- /dev/null +++ b/Imperative Programming/C-Characters-Arithmetics/ex0/ft_putnbr.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/05 13:17:20 by lclerel- #+# #+# */ +/* Updated: 2026/03/06 10:25:12 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +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 main(void) +{ + ft_putnbr(42); + ft_putnbr(-2147483647); + return (0); +}*/ diff --git a/Imperative Programming/C-Characters-Arithmetics/ex1/ft_print_comb.c b/Imperative Programming/C-Characters-Arithmetics/ex1/ft_print_comb.c new file mode 100644 index 0000000..ca5ce55 --- /dev/null +++ b/Imperative Programming/C-Characters-Arithmetics/ex1/ft_print_comb.c @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_comb.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/05 09:00:24 by lclerel- #+# #+# */ +/* Updated: 2026/03/06 10:56:51 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void print(char a, char b, char c) +{ + write(1, &a, 1); + write(1, &b, 1); + write(1, &c, 1); + if (!(a == '7' && b == '8' && c == '9')) + write(1, ", ", 2); +} + +void ft_print_comb(void) +{ + char a; + char b; + char c; + + a = '0'; + while (a <= '7') + { + b = a + 1; + while (b <= '8') + { + c = b + 1; + while (c <= '9') + { + print(a, b, c); + c++; + } + b++; + } + a++; + } +} + +/*int main(void) +{ + ft_print_comb(); + return (0); +}*/ diff --git a/Imperative Programming/C-Characters-Arithmetics/ex2/ft_print_comb2.c b/Imperative Programming/C-Characters-Arithmetics/ex2/ft_print_comb2.c new file mode 100644 index 0000000..87a310f --- /dev/null +++ b/Imperative Programming/C-Characters-Arithmetics/ex2/ft_print_comb2.c @@ -0,0 +1,50 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_comb2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/05 13:45:48 by lclerel- #+# #+# */ +/* Updated: 2026/03/05 19:09:34 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void print(char a, char space, char b) +{ + write(1, &"0123456789"[a / 10], 1); + write(1, &"0123456789"[a % 10], 1); + write(1, &space, 1); + write(1, &"0123456789"[b / 10], 1); + write(1, &"0123456789"[b % 10], 1); + if (!(a == 98 && b == 99)) + write(1, ", ", 2); +} + +void ft_print_comb2(void) +{ + char space; + char a; + char b; + + space = ' '; + a = 0; + while (a <= 98) + { + b = a + 1; + while (b <= 99) + { + print(a, space, b); + b++; + } + a++; + } +} + +/*int main(void) +{ + ft_print_comb2(); + return (0); +}*/ diff --git a/Imperative Programming/C-Characters-Arithmetics/ex3/ft_print_combn.c b/Imperative Programming/C-Characters-Arithmetics/ex3/ft_print_combn.c new file mode 100644 index 0000000..3c629fe --- /dev/null +++ b/Imperative Programming/C-Characters-Arithmetics/ex3/ft_print_combn.c @@ -0,0 +1,72 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_combn.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/05 19:08:08 by lclerel- #+# #+# */ +/* Updated: 2026/03/05 19:08:53 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_put_tab(int *tab, int n) +{ + int i; + char c; + + i = 0; + while (i < n) + { + c = tab[i] + '0'; + write(1, &c, 1); + i++; + } + if (tab[0] != (10 - n)) + { + write(1, ", ", 2); + } +} + +void ft_recursive(int *tab, int n, int pos, int start) +{ + int i; + + if (pos == n) + { + ft_put_tab(tab, n); + return ; + } + i = start; + while (i <= 9) + { + tab[pos] = i; + ft_recursive(tab, n, pos + 1, i + 1); + i++; + } +} + +void ft_print_combn(int n) +{ + int tab[10]; + + if (n > 0 && n < 10) + { + ft_recursive(tab, n, 0, 0); + } +} + +/*int main(void) +{ + write(1, "Test n = 2 :\n", 13); + ft_print_combn(2); + write(1, "\n\n", 2); + write(1, "Test n = 3 :\n", 13); + ft_print_combn(3); + write(1, "\n\n", 2); + write(1, "Test n = 9 :\n", 13); + ft_print_combn(9); + write(1, "\n\n", 2); +}*/ diff --git a/Imperative Programming/C-Programming-Fundamentals b/Imperative Programming/C-Programming-Fundamentals deleted file mode 160000 index aafa0cd..0000000 --- a/Imperative Programming/C-Programming-Fundamentals +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aafa0cd88947e5da02750653e104e091591ae1b9 diff --git a/Imperative Programming/C-Programming-Fundamentals/ex0/ft_putchar.c b/Imperative Programming/C-Programming-Fundamentals/ex0/ft_putchar.c new file mode 100644 index 0000000..ca1c704 --- /dev/null +++ b/Imperative Programming/C-Programming-Fundamentals/ex0/ft_putchar.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/04 09:24:28 by lclerel- #+# #+# */ +/* Updated: 2026/03/04 14:03:05 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} diff --git a/Imperative Programming/C-Programming-Fundamentals/ex1/ft_print_alphabet.c b/Imperative Programming/C-Programming-Fundamentals/ex1/ft_print_alphabet.c new file mode 100644 index 0000000..333ffc1 --- /dev/null +++ b/Imperative Programming/C-Programming-Fundamentals/ex1/ft_print_alphabet.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_alphabet.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/04 09:53:03 by lclerel- #+# #+# */ +/* Updated: 2026/03/04 14:06:37 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_print_alphabet(void) +{ + write(1, "abcdefghijklmnopqrstuvwxyz", 26); +} diff --git a/Imperative Programming/C-Programming-Fundamentals/ex2/ft_print_reverse_alphabet.c b/Imperative Programming/C-Programming-Fundamentals/ex2/ft_print_reverse_alphabet.c new file mode 100644 index 0000000..d3cbf4a --- /dev/null +++ b/Imperative Programming/C-Programming-Fundamentals/ex2/ft_print_reverse_alphabet.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_reverse_alphabet.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/04 13:27:15 by lclerel- #+# #+# */ +/* Updated: 2026/03/04 13:48:03 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_print_reverse_alphabet(void) +{ + write(1, "zyxwvutsrqponmlkjihgfedcba", 26); +} diff --git a/Imperative Programming/C-Programming-Fundamentals/ex3/ft_print_numbers.c b/Imperative Programming/C-Programming-Fundamentals/ex3/ft_print_numbers.c new file mode 100644 index 0000000..605b0c8 --- /dev/null +++ b/Imperative Programming/C-Programming-Fundamentals/ex3/ft_print_numbers.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_numbers.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/04 10:06:13 by lclerel- #+# #+# */ +/* Updated: 2026/03/04 14:08:05 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_print_numbers(void) +{ + write(1, "0123456789", 10); +} diff --git a/Imperative Programming/C-Programming-Fundamentals/ex4/ft_is_negative.c b/Imperative Programming/C-Programming-Fundamentals/ex4/ft_is_negative.c new file mode 100644 index 0000000..c152711 --- /dev/null +++ b/Imperative Programming/C-Programming-Fundamentals/ex4/ft_is_negative.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_is_negative.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/04 10:08:57 by lclerel- #+# #+# */ +/* Updated: 2026/03/04 16:11:32 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_is_negative(int n) +{ + char c; + + if (n >= 0) + { + c = 'P'; + } + else + { + c = 'N'; + } + write(1, &c, 1); +} diff --git a/Memory Management/C-Function-Pointers b/Memory Management/C-Function-Pointers deleted file mode 160000 index cff0d52..0000000 --- a/Memory Management/C-Function-Pointers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cff0d52035b2b181b55f1d4d6ecad03f88214aba diff --git a/Memory Management/C-Function-Pointers/ex0/ft_foreach.c b/Memory Management/C-Function-Pointers/ex0/ft_foreach.c new file mode 100644 index 0000000..d602f7b --- /dev/null +++ b/Memory Management/C-Function-Pointers/ex0/ft_foreach.c @@ -0,0 +1,66 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_foreach.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/12 09:38:54 by lclerel- #+# #+# */ +/* Updated: 2026/03/17 11:36:19 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_foreach(int *tab, int length, void (*f)(int)) + +{ + int i; + + i = 0; + while (i < length) + { + f(tab[i]); + i++; + } +} +/* +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 main(void) +{ + int tab[4] = {1, 8, 9, 6}; + int i; + int length; + i = 0; + length = 4; + + write(1, "Test avec tableau de 4, avec valeur 1 8 9 6 : ", 46); + write(1, "\n", 1); + while (i < length) + { + ft_putnbr(tab[i]); + i++; + write(1, "\n", 1); + } +}*/ diff --git a/Memory Management/C-Function-Pointers/ex1/ft_map.c b/Memory Management/C-Function-Pointers/ex1/ft_map.c new file mode 100644 index 0000000..eee26a0 --- /dev/null +++ b/Memory Management/C-Function-Pointers/ex1/ft_map.c @@ -0,0 +1,80 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/12 09:41:12 by lclerel- #+# #+# */ +/* Updated: 2026/03/17 11:36:53 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int *ft_map(int *tab, int length, int (*f)(int)) +{ + int i; + int *tab2; + + tab2 = malloc(sizeof(int) * length); + i = 0; + if (!tab2) + { + return (NULL); + } + while (i < length) + { + tab2[i] = f(tab[i]); + i++; + } + return (tab2); +} +/* +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_carre(int n) +{ + return (n * n); +} + +int main(void) +{ + int tab[4] = {1, 8, 9, 6}; + int *result = ft_map(tab, 4, &ft_carre); + int i; + int length; + + i = 0; + length = 4; + + write(1, "Test avec tableau de 4, avec valeur 1 8 9 6 : ", 46); + write(1, "\n", 1); + while (i < length) + { + ft_putnbr(result[i]); + i++; + write(1, "\n", 1); + } +}*/ diff --git a/Memory Management/C-Function-Pointers/ex2/ft_any.c b/Memory Management/C-Function-Pointers/ex2/ft_any.c new file mode 100644 index 0000000..d0208e0 --- /dev/null +++ b/Memory Management/C-Function-Pointers/ex2/ft_any.c @@ -0,0 +1,58 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_any.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/12 11:29:41 by lclerel- #+# #+# */ +/* Updated: 2026/03/17 11:37:55 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_any(char **tab, int (*f)(char*)) +{ + int i; + + i = 0; + while (tab[i] != NULL) + { + if (f(tab[i]) != 0) + { + return (1); + } + i++; + } + return (0); +} +/* +int s_check(char *s) +{ + int i = 0; + + while (s[i] == 'S') + { + return (1); + i++; + } + return (0); +} + +int main(void) +{ + char *tab[] = {"Test", "1234", "Test56", "singesavant", NULL}; + int result; + + result = ft_any(tab, &s_check); + if (result == 1) + { + write(1, "Un mot a ete trouver\n", 22); + } + else + { + write(1, "Rien trouver.\n", 14); + } + return (0); +}*/ diff --git a/Memory Management/C-Function-Pointers/ex3/ft_count_if.c b/Memory Management/C-Function-Pointers/ex3/ft_count_if.c new file mode 100644 index 0000000..7b9f4a7 --- /dev/null +++ b/Memory Management/C-Function-Pointers/ex3/ft_count_if.c @@ -0,0 +1,96 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_count_if.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/12 11:54:32 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 11:56:49 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_count_if(char **tab, int length, int (*f)(char*)) +{ + int i; + int count; + + i = 0; + count = 0; + if (!tab || !f) + { + return (0); + } + while (i < length) + { + if (f(tab[i]) != 0) + { + count++; + } + i++; + } + return (count); +} + +/*int len_check(char *s) +{ + int i = 0; + + while (s[i]) + { + i++; + } + if (i > 3) + { + return (1); + } + return (0); +} + +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 main(void) +{ + char *tab[] = {"Test", "1234", "Test56", "singesavant", NULL}; + int result; + int length = 0; + + while (tab[length] != NULL) + { + length++; + } + result = ft_count_if(tab, length, &len_check); + if (result > 1) + { + write(1, "Plusieurs mots ont ete trouver\n", 31); + write(1, "Nombre Total : ", 15); + ft_putnbr(result); + } + else + { + write(1, "Rien trouver.\n", 14); + } + return (0); +}*/ diff --git a/Memory Management/C-Function-Pointers/ex4/ft_is_sort.c b/Memory Management/C-Function-Pointers/ex4/ft_is_sort.c new file mode 100644 index 0000000..e97d0c5 --- /dev/null +++ b/Memory Management/C-Function-Pointers/ex4/ft_is_sort.c @@ -0,0 +1,105 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_is_sort.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/13 14:01:47 by lclerel- #+# #+# */ +/* Updated: 2026/03/17 11:39:02 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_is_sort(int *tab, int length, int (*f)(int, int)) +{ + int i; + int cs; + int ds; + + i = 0; + cs = 1; + ds = 1; + if (length <= 1) + { + return (1); + } + while (i < length - 1) + { + if (f(tab[i], tab[i + 1]) > 0) + { + cs = 0; + } + if (f(tab[i], tab[i + 1]) < 0) + { + ds = 0; + } + i++; + } + return (cs || ds); +} + +/* +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_compare(int a, int b) +{ + return (a - b); +} + +int main(void) +{ + int croiss[] = {1, 2, 3, 4, 5, 6, 6, 7}; + int decroiss[] = {7, 6, 6, 5, 4, 3, 2, 1}; + int pas_trie[] = {1, 2, 3, 5, 6, 7, 6, 9}; + int neg[] = {-1, -12, 11, -19}; + + write(1, "Test Croissant > (1, 2, 3, 4, 5, 6, 6, 7) : ", 44); + if (ft_is_sort(croiss, 8, &ft_compare) == 1) + write(1, "Ok :3 (Trié)\n", 14); + else + write(1, "Not ok (Pas trié)\n", 19); + + // Test 2 : Décroissant + write(1, "Test Decroissant > (7, 6, 6, 5, 4, 3, 2, 1) : ", 46); + if (ft_is_sort(decroiss, 8, &ft_compare) == 1) + write(1, "Ok :3 (Trié)\n", 14); + else + write(1, "Not ok (Pas trié)\n", 19); + + // Test 3 : Pas trié + write(1, "Test Pas trier > (1, 2, 3, 5, 6, 7, 6, 9) : ", 44); + if (ft_is_sort(pas_trie, 8, &ft_compare) == 1) + write(1, "Ok :3 (Trié)\n", 14); + else + write(1, "Not ok (Pas trié)\n", 19); + + // Test 4 : Negatif + write(1, "Test avec negatif > (-1, -12, 11, -19) : ", 42); + if (ft_is_sort(neg, 4, &ft_compare) == 1) + write(1, "Ok :3 (Trié)\n", 14); + else + write(1, "Not ok (Pas trié)\n", 19); + return (0); +}*/ diff --git a/Memory Management/C-Memory-Management b/Memory Management/C-Memory-Management deleted file mode 160000 index 3841fc1..0000000 --- a/Memory Management/C-Memory-Management +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3841fc1ff0628b9bb4b96f2dbd9ba05108ca6611 diff --git a/Memory Management/C-Memory-Management/ex0/ft_strdup.c b/Memory Management/C-Memory-Management/ex0/ft_strdup.c new file mode 100644 index 0000000..1eea4de --- /dev/null +++ b/Memory Management/C-Memory-Management/ex0/ft_strdup.c @@ -0,0 +1,71 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/16 14:01:43 by lclerel- #+# #+# */ +/* Updated: 2026/03/23 10:11:54 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +char *ft_strdup(char *src) +{ + int i; + int len; + char *dst; + + i = 0; + len = 0; + if (src == NULL) + return (NULL); + while (src[len]) + len++; + dst = malloc(sizeof(char) * (len + 1)); + if (dst == NULL) + { + return (NULL); + } + while (i < len) + { + dst[i] = src[i]; + i++; + } + dst[i] = '\0'; + return (dst); +} + +/*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 *dest; + + dest = ft_strdup(NULL); + + if (dest == NULL) + { + return (1); + } + ft_putstr(dest); + free(dest); +}*/ diff --git a/Memory Management/C-Memory-Management/ex1/ft_range.c b/Memory Management/C-Memory-Management/ex1/ft_range.c new file mode 100644 index 0000000..e6d9948 --- /dev/null +++ b/Memory Management/C-Memory-Management/ex1/ft_range.c @@ -0,0 +1,116 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/16 14:44:51 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 14:05:04 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int *ft_range(int min, int max) +{ + int *range; + int i; + int size; + + i = 0; + if (min >= max) + { + return (NULL); + } + size = max - min; + range = malloc(sizeof(int) * size); + if (!range) + { + return (NULL); + } + while (i < size) + { + range[i] = min + i; + i++; + } + return (range); +} + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +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 main(void) +{ + int *tab; + int min = 2; + int max = 10; + int i = 0; + + // TEST 1 : Cas Normal + tab = ft_range(min, max); + write(1, "/~~~Test 1~~~\\\n", 15); + write(1, "> Min : ", 8); + ft_putnbr(min); + write(1, " <\n> Max : ", 11); + ft_putnbr(max); + write(1, " <\n> Resultat : ", 16); + if (!tab) + write(1, "NULL", 4); + else + { + while (i < (max - min)) + { + ft_putnbr(tab[i]); + if (i < (max - min - 1)) + write(1, ", ", 2); + i++; + } + } + write(1, " <\n\\~~~Test 1~~~/\n\n", 18); + free(tab); + // TEST 2 : Cas Erreur (Min > Max) + int min_err = 9; + int max_err = 2; + int *tab_err = ft_range(min_err, max_err); + + write(1, "/~~~Test 2~~~\\\n", 15); + write(1, "> Min : ", 8); + ft_putnbr(min_err); + write(1, " <\n> Max : ", 11); + ft_putnbr(max_err); + write(1, " <\n> Resultat : ", 16); + if (!tab_err) + write(1, "NULL (OK)", 9); + else + write(1, "ERREUR : Devrait etre NULL", 26); + write(1, " <\n\\~~~Test 2~~~/\n", 18); + if (tab_err) + free(tab_err); + return (0); +} diff --git a/Memory Management/C-Memory-Management/ex2/ft_ultimate_range.c b/Memory Management/C-Memory-Management/ex2/ft_ultimate_range.c new file mode 100644 index 0000000..0319f71 --- /dev/null +++ b/Memory Management/C-Memory-Management/ex2/ft_ultimate_range.c @@ -0,0 +1,125 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ultimate_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/16 16:07:45 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 19:23:18 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int ft_ultimate_range(int **range, int min, int max) +{ + int i; + int *tab; + int size; + + i = 0; + if (min >= max) + { + *range = NULL; + return (0); + } + size = max - min; + tab = malloc(sizeof(int) * size); + if (!tab) + { + *range = NULL; + return (-1); + } + while (i < size) + { + tab[i] = min + i; + i++; + } + *range = tab; + return (size); +} +/* +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +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 main(void) +{ + int *tab; + int min = 2; + int max = 10; + int size; + // Integers pour les errors + int max_err = 2; + int min_err = 9; + int *tab_err; + int size_err; + // Integers pour le 3eme Test + int max2 = -5; + int min2 = -1; + int *tab2; + int size2; + size_err = ft_ultimate_range(&tab_err ,min_err, max_err); + size = ft_ultimate_range(&tab, min, max); + size2 = ft_ultimate_range(&tab2, min2, max2); + if (size == -1) + { + return (1); + } + // Test 1, Test Min 2 Max 10. + write(1, "/~~~Test 1~~~\\ \n", 16); + write(1, "> Min : ", 8); + ft_putnbr(min); + write(1, " <\n> Max : ", 11); + ft_putnbr(max); + write(1, " <\n> Resultat : ", 17); + ft_putnbr(size); + write(1, " <\n\\~~~Test 1~~~/", 18); + ft_putchar('\n'); + // Test 2, Test Min 9 Max 2 (Return Error) + write(1, "/~~~Test 2~~~\\ \n", 16); + write(1, "> Min : ", 8); + ft_putnbr(min_err); + write(1, " <\n> Max : ", 11); + ft_putnbr(max_err); + write(1, " <\n> Resultat : ", 17); + ft_putnbr(size_err); + write(1, " <\n\\~~~Test 2~~~/", 18); + ft_putchar('\n'); + // Test 3, Test Min -1 Max -5. + write(1, "/~~~Test 3~~~\\ \n", 16); + write(1, "> Min : ", 8); + ft_putnbr(min2); + write(1, " <\n> Max : ", 11); + ft_putnbr(max2); + write(1, " <\n> Resultat : ", 17); + ft_putnbr(size2); + write(1, " <\n\\~~~Test 3~~~/", 18); + ft_putchar('\n'); + free(tab); +}*/ diff --git a/Memory Management/C-Memory-Management/ex3/ft_strjoin.c b/Memory Management/C-Memory-Management/ex3/ft_strjoin.c new file mode 100644 index 0000000..b91de34 --- /dev/null +++ b/Memory Management/C-Memory-Management/ex3/ft_strjoin.c @@ -0,0 +1,133 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/16 16:37:56 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 19:24:56 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} + +int get_total_len(int size, char **strs, char *sep) +{ + int i; + int total; + + i = 0; + total = 0; + while (i < size) + { + total = total + ft_strlen(strs[i]); + if (i < size - 1) + { + total = total + ft_strlen(sep); + } + i++; + } + return (total); +} + +char *ft_strcat(char *dest, char *src) +{ + int i; + int j; + + i = 0; + j = 0; + while (dest[i]) + { + i++; + } + while (src[j]) + { + dest[i + j] = src[j]; + j++; + } + dest[i + j] = '\0'; + return (dest); +} + +char *ft_strjoin(int size, char **strs, char *sep) +{ + char *res; + int i; + int len; + + i = 0; + if (size == 0) + { + res = malloc(1); + if (res) + res[0] = '\0'; + return (res); + } + len = get_total_len(size, strs, sep); + res = malloc(sizeof(char) * (len + 1)); + if (!res) + return (NULL); + res[0] = '\0'; + while (i < size) + { + ft_strcat(res, strs[i]); + if (i < size - 1) + ft_strcat(res, sep); + i++; + } + return (res); +} +/* +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 *tab[5]; + char *result; + char *space; + + tab[0] = "Salut"; + tab[1] = "Je"; + tab[2] = "Suis"; + tab[3] = "Lumi"; + tab[4] = "!"; + space = " "; + result = ft_strjoin(5, tab, space); + if (result) + { + ft_putstr(result); + ft_putstr("\n"); + free(result); + } + return (0); +}*/ diff --git a/Memory Management/C-Memory-Management/ex4/ft_convert_base.c b/Memory Management/C-Memory-Management/ex4/ft_convert_base.c new file mode 100644 index 0000000..0e94022 --- /dev/null +++ b/Memory Management/C-Memory-Management/ex4/ft_convert_base.c @@ -0,0 +1,200 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convert_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/17 14:20:07 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 11:36:19 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +void ft_putstr(char *str); + +int ft_strlen(char *str); + +int ft_nbrlen(long nbr, int base_size); + +int check_base(char *base); + +int ft_index(char c, char *base) +{ + int i; + + i = 0; + while (base[i]) + { + if (base[i] == c) + return (i); + i++; + } + return (-1); +} + +int ft_atoi_base(char *str, char *base) +{ + int i; + int sign; + long res; + + res = 0; + i = 0; + sign = 1; + while (str[i] == ' ' || (str[i] >= 9 && str[i] <= 13)) + i++; + while (str[i] == '-' || str[i] == '+') + { + if (str[i++] == '-') + sign *= -1; + } + while (str[i]) + { + if (str[i] && ft_index(str[i], base) != -1) + { + res = (res * ft_strlen(base)) + ft_index(str[i], base); + i++; + } + } + return (res * sign); +} + +void ft_populate_res(char *res, long n, char *base_to, int size) +{ + int base_len; + + base_len = ft_strlen(base_to); + res[size] = '\0'; + if (n == 0) + res[0] = base_to[0]; + if (n < 0) + { + res[0] = '-'; + n = -n; + } + while (n > 0) + { + res[size - 1] = base_to[n % base_len]; + n /= base_len; + size--; + } +} + +char *ft_convert_base(char *nbr, char *base_from, char *base_to) +{ + long n; + char *res; + int size; + + if (!nbr || !base_from || !base_to) + return (NULL); + if (!check_base(base_from) || !check_base(base_to)) + return (NULL); + n = ft_atoi_base(nbr, base_from); + size = ft_nbrlen(n, ft_strlen(base_to)); + res = malloc(sizeof(char) * (size + 1)); + if (!res) + return (NULL); + ft_populate_res(res, n, base_to, size); + return (res); +} + +int main(void) +{ + char *result; + char *hex; + char *bin; + char *dec; + char *vif; + + hex = "0123456789abcdef"; + dec = "0123456789"; + bin = "01"; + vif = "poneyvif"; + // Test 1 : 42 > Dec to Bin + ft_putstr("Test avec 42 | "); + ft_putstr("Base From : Decimal (Base 10), Base To : Binary (Base 2)"); + write(1, "\n", 1); + result = ft_convert_base("42", dec, bin); + if (result == NULL) + { + write(1, "Erreur.", 7); + } + ft_putstr("Resultat : "); + ft_putstr(result); + write(1, "\n", 1); + free(result); + // Test 2 : 2a (42) > Hex to Vif + ft_putstr("Test avec 42 (2a) | "); + ft_putstr("Base From : Hexadecimal (Base 16), Base To : poneyvif (Base 8)"); + write(1, "\n", 1); + result = ft_convert_base("2a", hex, vif); + if (result == NULL) + { + write(1, "Erreur.", 7); + } + ft_putstr("Resultat : "); + ft_putstr(result); + write(1, "\n", 1); + free(result); + // Test 3 : 0 > Dec to Bin + ft_putstr("Test avec 0 | "); + ft_putstr("Base From : Decimal (Base 10), Base To : Binary (Base 2)"); + write(1, "\n", 1); + result = ft_convert_base("0", dec, bin); + if (result == NULL) + { + write(1, "Erreur.", 7); + } + ft_putstr("Resultat : "); + ft_putstr(result); + write(1, "\n", 1); + free(result); + // Test 4 : -2147483648 > Dec to Hex + ft_putstr("Test avec -2147483648 | "); + ft_putstr("Base From : Decimal (Base 10), Base To : Hexadecimal (Base 16)"); + write(1, "\n", 1); + result = ft_convert_base("-2147483648", dec, hex); + if (result == NULL) + { + write(1, "Erreur.", 7); + } + ft_putstr("Resultat : "); + ft_putstr(result); + write(1, "\n", 1); + free(result); + // Test 5 : Bordel Ultime > Binary to Dec + ft_putstr("Test avec ---+--101010 | "); + ft_putstr("Base From : Binary (Base 2), Base To : Decimal (Base 10)"); + write(1, "\n", 1); + result = ft_convert_base(" ---+--101010", bin, dec); + if (result == NULL) + { + write(1, "Erreur.", 7); + } + ft_putstr("Resultat : "); + ft_putstr(result); + write(1, "\n", 1); + free(result); + // Test 6 : NULL > Binary to Dec + // ft_putstr("Test avec NULL | "); + ft_putstr("Base From : Binary (Base 2), Base To : Decimal (Base 10)"); + write(1, "\n", 1); + result = ft_convert_base(NULL, bin, dec); + if (result == NULL) + { + write(1, "Erreur. NULL est mis comme variable", 35); + write(1, "\n", 1); + } + else + { + ft_putstr("Resultat : "); + ft_putstr(result); + write(1, "\n", 1); + free(result); + } + return (0); +} diff --git a/Memory Management/C-Memory-Management/ex4/ft_convert_base2.c b/Memory Management/C-Memory-Management/ex4/ft_convert_base2.c new file mode 100644 index 0000000..f3efc4f --- /dev/null +++ b/Memory Management/C-Memory-Management/ex4/ft_convert_base2.c @@ -0,0 +1,82 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convert_base2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/17 14:22:20 by lclerel- #+# #+# */ +/* Updated: 2026/03/17 18:16:30 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} + +void ft_putstr(char *str) +{ + int i; + + i = 0; + while (str[i]) + { + write(1, &str[i], 1); + i++; + } +} + +int ft_nbrlen(long nbr, int base_size) +{ + int len; + + len = 0; + if (nbr <= 0) + { + len++; + if (nbr < 0) + nbr = -nbr; + } + while (nbr > 0) + { + nbr /= base_size; + len++; + } + return (len); +} + +int check_base(char *base) +{ + int i; + int j; + + i = 0; + if (!base[0] || !base[1]) + return (0); + while (base[i]) + { + if (base[i] == '+' || base[i] == '-' + || (base[i] >= 9 && base[i] <= 13) + || base[i] == 32) + return (0); + j = i + 1; + while (base[j]) + { + if (base[i] == base[j]) + return (0); + j++; + } + i++; + } + return (1); +} diff --git a/Memory Management/C-Memory-Management/ex5/ft_split.c b/Memory Management/C-Memory-Management/ex5/ft_split.c new file mode 100644 index 0000000..a6959f8 --- /dev/null +++ b/Memory Management/C-Memory-Management/ex5/ft_split.c @@ -0,0 +1,117 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/18 10:29:59 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 19:27:27 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +int ft_sep(char c, char *charset) +{ + int i; + + i = 0; + while (charset[i]) + { + if (c == charset[i]) + return (1); + i++; + } + return (0); +} + +int ft_words(char *str, char *charset) +{ + int i; + int count; + + count = 0; + i = 0; + while (str[i]) + { + if (ft_sep(str[i], charset) == 0 + && (i == 0 || ft_sep(str[i - 1], charset) == 1)) + { + count++; + } + i++; + } + return (count); +} + +char *ft_get_word(char *str, char *charset) +{ + char *word; + int i; + int len; + + len = 0; + i = 0; + while (str[len] && ft_sep(str[len], charset) == 0) + len++; + word = malloc(sizeof(char) * (len + 1)); + if (!word) + return (NULL); + while (i < len) + { + word[i] = str[i]; + i++; + } + word[i] = '\0'; + return (word); +} + +char **ft_split(char *str, char *charset) +{ + char **res; + int i; + int j; + + i = 0; + j = 0; + res = malloc(sizeof(char *) * (ft_words(str, charset) + 1)); + if (!res) + return (NULL); + while (str[i]) + { + while (str[i] && ft_sep(str[i], charset) == 1) + i++; + if (str[i]) + { + res[j++] = ft_get_word(&str[i], charset); + while (str[i] && ft_sep(str[i], charset) == 0) + i++; + } + } + res[j] = 0; + return (res); +} +/* +int main(void) +{ + char **res; + int i; + int j; + res = ft_split("Ceci Est+Un+Test^Fait/Par&Lumi.", "+-^/&"); + i = 0; + write(1, "Test avec : Ceci Est+Un-Test^Fait/Par&Lumi. : \n", 47); + while (res[i]) + { + j = 0; + while (res[i][j]) + { + write(1, &res[i][j], 1); + j++; + } + write(1, "\n", 1); + i++; + } + return (0); +}*/ diff --git a/Memory Management/C-Pointers b/Memory Management/C-Pointers deleted file mode 160000 index 09c4873..0000000 --- a/Memory Management/C-Pointers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 09c4873fe3890123df7010e55e40b98f6fa3764b diff --git a/Memory Management/C-Pointers/ex0/ft_ft.c b/Memory Management/C-Pointers/ex0/ft_ft.c new file mode 100644 index 0000000..143cbf8 --- /dev/null +++ b/Memory Management/C-Pointers/ex0/ft_ft.c @@ -0,0 +1,58 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ft.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 16:50:01 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 17:31:41 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_ft(int *nbr) +{ + *nbr = 42; +} + +/*int main(void) +{ + int a; + int *ptr1; + + a = 0; + ptr1 = &a; + + write(1, "Avant : ", 8); + ft_putnbr(a); + write(1, "\n", 1); + write(1, "Apres : ", 8); + ft_ft(ptr1); + ft_putnbr(*ptr1); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Memory Management/C-Pointers/ex1/ft_ultimate_ft.c b/Memory Management/C-Pointers/ex1/ft_ultimate_ft.c new file mode 100644 index 0000000..205e6dd --- /dev/null +++ b/Memory Management/C-Pointers/ex1/ft_ultimate_ft.c @@ -0,0 +1,74 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ultimate_ft.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 16:52:51 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 17:29:03 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_ultimate_ft(int *********nbr) +{ + *********nbr = 42; +} + +/*int main(void) +{ + int a; + int *ptr1; + int **ptr2; + int ***ptr3; + int ****ptr4; + int *****ptr5; + int ******ptr6; + int *******ptr7; + int ********ptr8; + int *********ptr9; + + a = 0; + ptr1 = &a; + ptr2 = &ptr1; + ptr3 = &ptr2; + ptr4 = &ptr3; + ptr5 = &ptr4; + ptr6 = &ptr5; + ptr7 = &ptr6; + ptr8 = &ptr7; + ptr9 = &ptr8; + + write(1, "Avant : ", 8); + ft_putnbr(a); + write(1, "\n", 1); + write(1, "Apres : ", 8); + ft_ultimate_ft(ptr9); + ft_putnbr(*********ptr9); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Memory Management/C-Pointers/ex2/ft_swap.c b/Memory Management/C-Pointers/ex2/ft_swap.c new file mode 100644 index 0000000..cdcd704 --- /dev/null +++ b/Memory Management/C-Pointers/ex2/ft_swap.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_swap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 17:36:15 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 17:46:32 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_swap(int *a, int *b) +{ + int tmp; + + tmp = *a; + *a = *b; + *b = tmp; +} + +/*int main(void) +{ + int a; + int b; + + a = 3; + b = 9; + write(1, "Avant - a: ", 11); + ft_putnbr(a); + write(1, "\n", 1); + write(1, "Avant - b: ", 11); + ft_putnbr(b); + write(1, "\n", 1); + ft_swap(&a, &b); + write(1, "\n", 1); + write(1, "Apres - a: ", 11); + ft_putnbr(a); + write(1, "\n", 1); + write(1, "Apres - b: ", 11); + ft_putnbr(b); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Memory Management/C-Pointers/ex3/ft_div_mod.c b/Memory Management/C-Pointers/ex3/ft_div_mod.c new file mode 100644 index 0000000..cd11e69 --- /dev/null +++ b/Memory Management/C-Pointers/ex3/ft_div_mod.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_div_mod.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 17:52:58 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 18:50:17 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_div_mod(int a, int b, int *div, int *mod) +{ + *div = a / b; + *mod = a % b; +} + +/*int main(void) +{ + int a; + int b; + int res_div; + int res_mod; + + a = 42; + b = 5; + res_div = 0; + res_mod = 0; + ft_div_mod(a, b, &res_div, &res_mod); + write(1, "Division de 42 par 5 :\n", 23); + write(1, "Quotient : ", 11); + ft_putnbr(res_div); + write(1, "\n", 1); + write(1, "Reste : ", 8); + ft_putnbr(res_mod); + write(1, "\n", 1); +}*/ diff --git a/Memory Management/C-Pointers/ex4/ft_ultimate_div_mod.c b/Memory Management/C-Pointers/ex4/ft_ultimate_div_mod.c new file mode 100644 index 0000000..89c1956 --- /dev/null +++ b/Memory Management/C-Pointers/ex4/ft_ultimate_div_mod.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ultimate_div_mod.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 18:53:55 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 19:05:23 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_ultimate_div_mod(int *a, int *b) +{ + int temp_a; + int temp_b; + + temp_a = *a; + temp_b = *b; + *a = temp_a / temp_b; + *b = temp_a % temp_b; +} + +/*int main(void) +{ + int a; + int b; + + a = 42; + b = 5; + write(1, "Avant : ", 8); + ft_putnbr(a); + write(1, " et ", 4); + ft_putnbr(b); + write(1, "\n", 1); + ft_ultimate_div_mod(&a, &b); + write(1, "Apres (Div) : ", 14); + ft_putnbr(a); + write(1, "\n", 1); + write(1, "Apres (Mod) : ", 14); + ft_putnbr(b); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Memory Management/C-Pointers/ex5/ft_rev_int_tab.c b/Memory Management/C-Pointers/ex5/ft_rev_int_tab.c new file mode 100644 index 0000000..33954bd --- /dev/null +++ b/Memory Management/C-Pointers/ex5/ft_rev_int_tab.c @@ -0,0 +1,76 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_rev_int_tab.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 19:08:40 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 19:23:29 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_rev_int_tab(int *tab, int size) +{ + int i; + int temp; + int last; + + i = 0; + last = size - 1; + while (i < size / 2) + { + temp = tab[i]; + tab[i] = tab[last]; + tab[last] = temp; + i++; + last--; + } +} + +/*int main(void) +{ + int tab[5] = {1, 2, 3, 4, 5}; + int size; + + size = 5; + write(1, "Avant : 1, 2, 3, 4, 5", 22); + ft_rev_int_tab(tab, size); + write(1, "\n", 1); + write(1, "Apres : ", 8); + ft_putnbr(tab[0]); + write(1, ", ", 2); + ft_putnbr(tab[1]); + write(1, ", ", 2); + ft_putnbr(tab[2]); + write(1, ", ", 2); + ft_putnbr(tab[3]); + write(1, ", ", 2); + ft_putnbr(tab[4]); + write(1, "\n", 1); + return (0); +}*/ diff --git a/Memory Management/C-Pointers/ex6/ft_sort_int_tab.c b/Memory Management/C-Pointers/ex6/ft_sort_int_tab.c new file mode 100644 index 0000000..9ffadbc --- /dev/null +++ b/Memory Management/C-Pointers/ex6/ft_sort_int_tab.c @@ -0,0 +1,87 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_int_tab.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/09 19:24:29 by lclerel- #+# #+# */ +/* Updated: 2026/03/09 19:34:56 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ + +void ft_sort_int_tab(int *tab, int size) +{ + int i; + int temp; + int changed; + + changed = 1; + while (changed) + { + changed = 0; + i = 0; + while (i < size -1) + { + if (tab[i] > tab[i + 1]) + { + temp = tab[i]; + tab[i] = tab[i + 1]; + tab[i + 1] = temp; + changed = 1; + } + i++; + } + } +} + +/*int main(void) +{ + int tab[] = {5, 1, 4, 2, 8, 9, 3, 7, 6}; + int size = 9; + + ft_sort_int_tab(tab, size); + ft_putnbr(tab[0]); + write(1, ", ", 2); + ft_putnbr(tab[1]); + write(1, ", ", 2); + ft_putnbr(tab[2]); + write(1, ", ", 2); + ft_putnbr(tab[3]); + write(1, ", ", 2); + ft_putnbr(tab[4]); + write(1, ", ", 2); + ft_putnbr(tab[5]); + write(1, ", ", 2); + ft_putnbr(tab[6]); + write(1, ", ", 2); + ft_putnbr(tab[7]); + write(1, ", ", 2); + ft_putnbr(tab[8]); + write(1, "\n ", 1); + return (0); +}*/ diff --git a/Memory Management/C-Simple-Strings b/Memory Management/C-Simple-Strings deleted file mode 160000 index 5838a52..0000000 --- a/Memory Management/C-Simple-Strings +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5838a52b609fc3d16355ee6e8c4294749f3f45d0 diff --git a/Memory Management/C-Simple-Strings/ex0/#ft_str_is_alpha.c# b/Memory Management/C-Simple-Strings/ex0/#ft_str_is_alpha.c# new file mode 100644 index 0000000..416d75d --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex0/#ft_str_is_alpha.c# @@ -0,0 +1,55 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_alpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 13:14:35 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex0/ft_str_is_alpha.c b/Memory Management/C-Simple-Strings/ex0/ft_str_is_alpha.c new file mode 100644 index 0000000..cb2dcd1 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex0/ft_str_is_alpha.c @@ -0,0 +1,55 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_alpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 13:14:35 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex1/ft_str_is_numeric.c b/Memory Management/C-Simple-Strings/ex1/ft_str_is_numeric.c new file mode 100644 index 0000000..c96de2e --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex1/ft_str_is_numeric.c @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_numeric.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 11:31:44 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex10/ft_putstr_non_printable.c b/Memory Management/C-Simple-Strings/ex10/ft_putstr_non_printable.c new file mode 100644 index 0000000..fb891e1 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex10/ft_putstr_non_printable.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_non_printable.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 17:05:58 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 17:17:53 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +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); +} diff --git a/Memory Management/C-Simple-Strings/ex2/ft_str_is_lowercase.c b/Memory Management/C-Simple-Strings/ex2/ft_str_is_lowercase.c new file mode 100644 index 0000000..5491634 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex2/ft_str_is_lowercase.c @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_lowercase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 13:15:46 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex3/ft_str_is_uppercase.c b/Memory Management/C-Simple-Strings/ex3/ft_str_is_uppercase.c new file mode 100644 index 0000000..7a2ebda --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex3/ft_str_is_uppercase.c @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_uppercase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 09:59:54 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 11:43:39 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex4/ft_str_is_printable.c b/Memory Management/C-Simple-Strings/ex4/ft_str_is_printable.c new file mode 100644 index 0000000..2569ef1 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex4/ft_str_is_printable.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_printable.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 12:02:31 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 13:16:41 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex5/ft_strupcase.c b/Memory Management/C-Simple-Strings/ex5/ft_strupcase.c new file mode 100644 index 0000000..3fd4c99 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex5/ft_strupcase.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strupcase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 12:39:09 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 13:13:29 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex6/ft_strlowcase.c b/Memory Management/C-Simple-Strings/ex6/ft_strlowcase.c new file mode 100644 index 0000000..bc0f7fc --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex6/ft_strlowcase.c @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlowcase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 12:39:09 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 18:44:55 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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_strlowcase(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_strlowcase(str); + write(1, "\n", 1); + write(1, "Apres : ", 8); + ft_putstr(str); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex7/ft_strcapitalize.c b/Memory Management/C-Simple-Strings/ex7/ft_strcapitalize.c new file mode 100644 index 0000000..56ef32b --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex7/ft_strcapitalize.c @@ -0,0 +1,66 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcapitalize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 14:30:14 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 16:07:45 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex8/ft_strlen.c b/Memory Management/C-Simple-Strings/ex8/ft_strlen.c new file mode 100644 index 0000000..57439c3 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex8/ft_strlen.c @@ -0,0 +1,61 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 16:35:32 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 16:57:13 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +/*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); +}*/ diff --git a/Memory Management/C-Simple-Strings/ex9/ft_putstr.c b/Memory Management/C-Simple-Strings/ex9/ft_putstr.c new file mode 100644 index 0000000..cccba20 --- /dev/null +++ b/Memory Management/C-Simple-Strings/ex9/ft_putstr.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/10 14:04:52 by lclerel- #+# #+# */ +/* Updated: 2026/03/10 14:21:43 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +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); +}*/ diff --git a/Memory Management/C-System-Interface b/Memory Management/C-System-Interface deleted file mode 160000 index 4b8aa85..0000000 --- a/Memory Management/C-System-Interface +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4b8aa8530c1a8d261c3a0433360f23704c238b19 diff --git a/Memory Management/C-System-Interface/ex0/ft_print_program_name.c b/Memory Management/C-System-Interface/ex0/ft_print_program_name.c new file mode 100644 index 0000000..d219cc1 --- /dev/null +++ b/Memory Management/C-System-Interface/ex0/ft_print_program_name.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_program_name.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/19 15:36:50 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 18:05:56 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int i; + + (void)argc; + i = 0; + while (argv[0][i] != '\0') + i++; + write(1, argv[0], i); + write(1, "\n", 1); +} diff --git a/Memory Management/C-System-Interface/ex1/ft_print_params.c b/Memory Management/C-System-Interface/ex1/ft_print_params.c new file mode 100644 index 0000000..06447d6 --- /dev/null +++ b/Memory Management/C-System-Interface/ex1/ft_print_params.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/19 16:03:11 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 18:05:40 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int i; + int len; + + (void)argc; + i = 1; + while (i < argc) + { + len = 0; + while (argv[i][len] != '\0') + len++; + write(1, argv[i], len); + write(1, "\n", 1); + i++; + } + return (0); +} diff --git a/Memory Management/C-System-Interface/ex2/ft_rev_params.c b/Memory Management/C-System-Interface/ex2/ft_rev_params.c new file mode 100644 index 0000000..0df0548 --- /dev/null +++ b/Memory Management/C-System-Interface/ex2/ft_rev_params.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_rev_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/19 16:09:13 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 18:05:23 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int i; + int len; + + (void)argc; + i = argc - 1; + while (i > 0) + { + len = 0; + while (argv[i][len] != '\0') + len++; + write(1, argv[i], len); + write(1, "\n", 1); + i--; + } + return (0); +} diff --git a/Memory Management/C-System-Interface/ex3/ft_sort_params.c b/Memory Management/C-System-Interface/ex3/ft_sort_params.c new file mode 100644 index 0000000..27f8d79 --- /dev/null +++ b/Memory Management/C-System-Interface/ex3/ft_sort_params.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/19 16:47:37 by lclerel- #+# #+# */ +/* Updated: 2026/03/19 18:09:21 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] != '\0' && s1[i] == s2[i]) + i++; + return (s1[i] - s2[i]); +} + +void ft_display(int argc, char **argv) +{ + int i; + int len; + + i = 1; + while (i < argc) + { + len = 0; + while (argv[i][len]) + len++; + write(1, argv[i], len); + write(1, "\n", 1); + i++; + } +} + +int main(int argc, char **argv) +{ + int i; + int j; + char *temp; + + if (argc < 2) + return (0); + i = 1; + while (i < argc - 1) + { + j = i + 1; + while (j < argc) + { + if (ft_strcmp(argv[i], argv[j]) > 0) + { + temp = argv[i]; + argv[i] = argv[j]; + argv[j] = temp; + } + j++; + } + i++; + } + ft_display(argc, argv); + return (0); +} diff --git a/Shell/Git-Fundamentals b/Shell/Git-Fundamentals deleted file mode 160000 index a51f987..0000000 --- a/Shell/Git-Fundamentals +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a51f987eb7de36ec5c5eb53f0f27b1db8c6aea52 diff --git a/Shell/Git-Fundamentals/ex0/git_commit.sh b/Shell/Git-Fundamentals/ex0/git_commit.sh new file mode 100644 index 0000000..d4e2aa4 --- /dev/null +++ b/Shell/Git-Fundamentals/ex0/git_commit.sh @@ -0,0 +1 @@ +git log --format=%H -n 5 diff --git a/Shell/Git-Fundamentals/ex1/git_ignore.sh b/Shell/Git-Fundamentals/ex1/git_ignore.sh new file mode 100644 index 0000000..cdd4509 --- /dev/null +++ b/Shell/Git-Fundamentals/ex1/git_ignore.sh @@ -0,0 +1 @@ +git ls-files --ignored --others --exclude-standard diff --git a/Shell/Shell-Fundamentals b/Shell/Shell-Fundamentals deleted file mode 160000 index c7b83aa..0000000 --- a/Shell/Shell-Fundamentals +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c7b83aa8c5b1de487564ea5c5bb4156aaf888d4f diff --git a/Shell/Shell-Fundamentals/ex0/testShell00.tar b/Shell/Shell-Fundamentals/ex0/testShell00.tar new file mode 100644 index 0000000000000000000000000000000000000000..e5cdba3d3b8323c206469e4f52f65a4214753b86 GIT binary patch literal 10240 zcmeIuu?@o@5QX8BCt(3gXE1h^DLjD{A*Hwq<38JD&5%fz?8+70{~8Vs>EJ7AE6XdH zsYwxa_SdR5~{!dgHqSrahldrW7AxvIeyBD2)x^HF8&WSxOb>!3`K>WL>DMRN|ZSD6g@#vc=MDvdvDWgRt%(UQ6{k_c~PdoU3p;`UY zsDCZZCvN`F@c%u&8q+^JZ)E;2Q~kN?udV%e{}=ebvn&V?0>SEEoH?-$9oJX2S5KA;_6%mroXCA{D0_QrBs{$ ya;6euvgEvf0vud_XXz0h1V8`;KmY_l00ck)1V8`;KmY_l00ck)1VG>)3H$+3V3*tg literal 0 HcmV?d00001 diff --git a/Shell/Shell-Fundamentals/ex2/midLS b/Shell/Shell-Fundamentals/ex2/midLS new file mode 100644 index 0000000..02437b5 --- /dev/null +++ b/Shell/Shell-Fundamentals/ex2/midLS @@ -0,0 +1 @@ +ls -pmt diff --git "a/Shell/Shell-Fundamentals/ex3/\"\\?$*'MaRViN'*$?\\\"" "b/Shell/Shell-Fundamentals/ex3/\"\\?$*'MaRViN'*$?\\\"" new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ "b/Shell/Shell-Fundamentals/ex3/\"\\?$*'MaRViN'*$?\\\"" @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/Shell/Shell-Searching-And-Finding b/Shell/Shell-Searching-And-Finding deleted file mode 160000 index 8499e14..0000000 --- a/Shell/Shell-Searching-And-Finding +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8499e1449635a2d267cf3926f0bdbebb5b0c56e8 diff --git a/Shell/Shell-Searching-And-Finding/ex0/find_sh.sh b/Shell/Shell-Searching-And-Finding/ex0/find_sh.sh new file mode 100755 index 0000000..94a5693 --- /dev/null +++ b/Shell/Shell-Searching-And-Finding/ex0/find_sh.sh @@ -0,0 +1 @@ +find . -iname "*.sh" -execdir sh -c 'printf "%s\n" "${0%.*}"' {} ';' | cut -c3- diff --git a/Shell/Shell-Searching-And-Finding/ex1/clean b/Shell/Shell-Searching-And-Finding/ex1/clean new file mode 100755 index 0000000..62e1933 --- /dev/null +++ b/Shell/Shell-Searching-And-Finding/ex1/clean @@ -0,0 +1 @@ +find . -type f -name "*~" -print -delete -o -name "#*#" -print -delete diff --git a/Shell/Shell-Searching-And-Finding/ex2/count_files.sh b/Shell/Shell-Searching-And-Finding/ex2/count_files.sh new file mode 100755 index 0000000..0815deb --- /dev/null +++ b/Shell/Shell-Searching-And-Finding/ex2/count_files.sh @@ -0,0 +1 @@ +find | wc -l diff --git a/Tutorial/C-Project-Tutorial b/Tutorial/C-Project-Tutorial deleted file mode 160000 index d190b17..0000000 --- a/Tutorial/C-Project-Tutorial +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d190b1724014d7b1e0416c551b119be4424a0b35 diff --git a/Tutorial/C-Project-Tutorial/ex0/z b/Tutorial/C-Project-Tutorial/ex0/z new file mode 100644 index 0000000..e900b1c --- /dev/null +++ b/Tutorial/C-Project-Tutorial/ex0/z @@ -0,0 +1 @@ +Z diff --git a/Tutorial/C-Project-Tutorial/ex1/id_rsa_pub b/Tutorial/C-Project-Tutorial/ex1/id_rsa_pub new file mode 100644 index 0000000..86ad981 --- /dev/null +++ b/Tutorial/C-Project-Tutorial/ex1/id_rsa_pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAPAn1jNqiV6iBmIwRIUX0EgBuzW/kyfcL7mp4g8T+yCSzHTHXRA7DT5NefXjxvKkBezZ2cdg8XNv6FMYCQ3TxUSaP34vlgxA8WUu2iZFQZLtl1tXG1boNItRhK1KpsXKasj/T7FNwntqWpyQT+SYT6MQAQkg7V+ST9Y/fL5QzC6sV2g7rr/FM01QfVErFdiblgJx1y0JpqUui+nurz9kh+WSkssTYDPWNLHuFgUPgM14wlIl2SmqTlw6MajLt8GxYJmsVAASgvohlBNWYc/0a1uDgGFwy0ZjqNYoJANwqc+c5GEYX2FBmu1PDyeziZUmhWml5ddh5o+PdB8WkxXma9Vrygj/KESAUySNSguRO6daKUCl1X6/NqhJGhR0mjQzD9s0HENZGblVLZ6fbybkDaO4XSrNynIqvvDbouQJsneco/R9nFbLAadojQV2VPFgblCqlppRlF9btH9tR+7ehkwuOjGItrldyMGugCeYFue2itmsdC0FN+x8MLlQMUl0= syxpikiller@gmail.com