diff --git a/Data Structures/C-Strings/ex2/ft_strcmp.c b/Data Structures/C-Strings/ex2/ft_strcmp.c index a344ed9..69e76fe 100644 --- a/Data Structures/C-Strings/ex2/ft_strcmp.c +++ b/Data Structures/C-Strings/ex2/ft_strcmp.c @@ -6,7 +6,7 @@ /* By: lclerel- +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/24 13:44:05 by lclerel- #+# #+# */ -/* Updated: 2026/03/25 16:39:44 by lclerel- ### ########.fr */ +/* Updated: 2026/03/25 22:46:26 by lclerel- ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ int ft_strcmp(char *s1, char *s2) return ((unsigned char)s1[i] - (unsigned char)s2[i]); } -void ft_putchar(char chara) +/*void ft_putchar(char chara) { write(1, &chara, 1); } @@ -38,7 +38,7 @@ void ft_putstr(char *str) i++; } } -/* + int main(void) { char *s1 = "Lumi"; @@ -81,4 +81,4 @@ int main(void) ft_putchar('\n'); return (0); } -*/ \ No newline at end of file +*/ diff --git a/Data Structures/C-Strings/ex3/ft_strncmp.c b/Data Structures/C-Strings/ex3/ft_strncmp.c index bc2595a..4f17848 100644 --- a/Data Structures/C-Strings/ex3/ft_strncmp.c +++ b/Data Structures/C-Strings/ex3/ft_strncmp.c @@ -6,10 +6,11 @@ /* By: lclerel- +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/24 13:44:05 by lclerel- #+# #+# */ -/* Updated: 2026/03/25 16:39:14 by lclerel- ### ########.fr */ +/* Updated: 2026/03/25 22:46:55 by lclerel- ### ########.fr */ /* */ /* ************************************************************************** */ +#include int ft_strncmp(char *s1, char *s2, unsigned int n) { diff --git a/Data Structures/C-Structures/ex0/ft_point.h b/Data Structures/C-Structures/ex0/ft_point.h new file mode 100644 index 0000000..5711729 --- /dev/null +++ b/Data Structures/C-Structures/ex0/ft_point.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_point.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/25 22:49:49 by lclerel- #+# #+# */ +/* Updated: 2026/03/25 22:53:42 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_POINT_H +# define FT_POINT_H + +typedef struct s_point +{ + int x; + int y; +} t_point; + +#endif diff --git a/Data Structures/C-Structures/ex1/ft_strs_to_tab.c b/Data Structures/C-Structures/ex1/ft_strs_to_tab.c new file mode 100644 index 0000000..fa83559 --- /dev/null +++ b/Data Structures/C-Structures/ex1/ft_strs_to_tab.c @@ -0,0 +1,179 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strs_to_tab.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/25 22:54:18 by lclerel- #+# #+# */ +/* Updated: 2026/03/26 01:19:03 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include "ft_stock_str.h" + +char *ft_strdup(char *src); +int ft_strlen(char *str); + +struct s_stock_str *ft_strs_to_tab(int ac, char **av) +{ + t_stock_str *tab; + int i; + + i = 0; + tab = malloc((ac + 1) * sizeof(t_stock_str)); + if (!tab) + return (NULL); + while (i < ac) + { + tab[i].size = ft_strlen(av[i]); + tab[i].str = av[i]; + tab[i].copy = ft_strdup(av[i]); + i++; + } + tab[i].str = av[i]; + return (tab); +} + +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); +} + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} +/* +void ft_putstr(char *str) +{ + int i; + + if (!str) + return ; + i = 0; + while (str[i]) + { + write(1, &str[i], 1); + 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); +} + +void ft_stylebox(int n) +{ + while (n > 0) + { + write(1, " ", 1); + n--; + } +} + +int ft_nbrlen(int nb) +{ + int len; + + len = 1; + while (nb > 9) + { + nb /= 10; + len++; + } + return (len); +} + +int main(int argc, char **argv) +{ + t_stock_str *tab; + int i; + int spaces; + + tab = ft_strs_to_tab(argc, argv); + + if (!tab) + return (1); + + i = 0; + + while (tab[i].str != 0) + { + // Oui, cela ne sers a rien. A RIEN. + // mais c pour faire waw. et si sa te plait pas, bah... + // DARK MOULINETTE VA TE FAIRE DU SALE MON GARS ! + // - Lumi, 26 Mars 2026, 0h24. Entrain de sombrer dans la folie. + ft_putstr("/==========================\\\n"); + ft_putstr("| Taille : |\n"); + ft_putstr("| > "); + ft_putnbr(tab[i].size); + spaces = 26 - 4 - ft_nbrlen(tab[i].size); + ft_stylebox(spaces); + ft_putstr("|\n"); + ft_putstr("| String : |\n"); + ft_putstr("| > "); + ft_putstr(tab[i].str); + spaces = 26 - 4 - ft_strlen(tab[i].str); + ft_stylebox(spaces); + ft_putstr("|\n"); + ft_putstr("| |\n"); + ft_putstr("| Result : |\n"); + ft_putstr("| > "); + ft_putstr(tab[i].copy); + spaces = 26 - 4 - ft_strlen(tab[i].copy); + ft_stylebox(spaces); + ft_putstr("|\n"); + ft_putstr("\\==========================/\n\n"); + i++; + } + return (0); +}*/ diff --git a/Data Structures/C-Structures/ex2/ft_show_tab.c b/Data Structures/C-Structures/ex2/ft_show_tab.c new file mode 100644 index 0000000..f96c2a1 --- /dev/null +++ b/Data Structures/C-Structures/ex2/ft_show_tab.c @@ -0,0 +1,137 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_show_tab.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lclerel- +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/26 01:13:18 by lclerel- #+# #+# */ +/* Updated: 2026/03/26 01:40:26 by lclerel- ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include "ft_stock_str.h" + +void ft_putstr(char *str) +{ + int i; + + if (!str) + return ; + i = 0; + while (str[i]) + { + write(1, &str[i], 1); + 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); +} + +void ft_show_tab(struct s_stock_str *par) +{ + int i; + + i = 0; + while (par[i].str != 0) + { + ft_putstr(par[i].str); + write(1, "\n", 1); + ft_putnbr(par[i].size); + write(1, "\n", 1); + ft_putstr(par[i].copy); + write(1, "\n", 1); + i++; + } +} +/* +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i] != '\0') + { + i++; + } + return (i); +} + +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); +} + +struct s_stock_str *ft_strs_to_tab(int ac, char **av) +{ + t_stock_str *tab; + int i; + + i = 0; + tab = malloc((ac + 1) * sizeof(t_stock_str)); + if (!tab) + return (NULL); + while (i < ac) + { + tab[i].size = ft_strlen(av[i]); + tab[i].str = av[i]; + tab[i].copy = ft_strdup(av[i]); + i++; + } + tab[i].str = av[i]; + return (tab); +} + +int main(int argc, char **argv) +{ + t_stock_str *tab; + + tab = ft_strs_to_tab(argc, argv); + if (!tab) + return (1); + ft_show_tab(tab); + return (0); +}*/