commit fadb328b0512dacc2311c0ee56d09ff57bec78a1 Author: root Date: Mon Feb 23 00:04:03 2026 +0000 push diff --git a/ex0/ft_putchar.c b/ex0/ft_putchar.c new file mode 100644 index 0000000..32c10f4 --- /dev/null +++ b/ex0/ft_putchar.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 22:37:40 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:12:36 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +// int main(void) +// { +// ft_putchar('c'); +// return (0); +// } diff --git a/ex1/ft_print_alphabet.c b/ex1/ft_print_alphabet.c new file mode 100644 index 0000000..c6c5df9 --- /dev/null +++ b/ex1/ft_print_alphabet.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_alphabet.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 22:42:06 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:12:29 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +void ft_print_alphabet(void) +{ + int i; + + i = 97; + while (i <= 122) + ft_putchar(i++); +} + +// int main(void) +// { +// ft_print_alphabet(); +// return (0); +// } diff --git a/ex10/ft_strlowcase.c b/ex10/ft_strlowcase.c new file mode 100644 index 0000000..e9e3e3d --- /dev/null +++ b/ex10/ft_strlowcase.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlowcase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:26:17 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:30:43 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strlowcase(char *str) +{ + int i; + + i = 0; + while (str[i]) + { + if (str[i] >= 'A' && str[i] <= 'Z') + str[i] += 32; + i++; + } + return (str); +} + +// #include + +// int main(void) +// { +// char str[] = "HelLLo212FFFFFff @#@#"; +// printf("%s", ft_strlowcase(str)); +// } \ No newline at end of file diff --git a/ex11/ft_strcpy.c b/ex11/ft_strcpy.c new file mode 100644 index 0000000..2fadd69 --- /dev/null +++ b/ex11/ft_strcpy.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:31:17 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:38:22 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcpy(char *dest, char *src) +{ + int i; + + i = 0; + while (src[i]) + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return (dest); +} + +// #include + +// int main(void) +// { +// char src[] = "hello"; +// char dest[10]; + +// ft_strcpy(dest, src); +// printf("%s", dest); +// return (0); +// } \ No newline at end of file diff --git a/ex12/ft_ft.c b/ex12/ft_ft.c new file mode 100644 index 0000000..d9cb2af --- /dev/null +++ b/ex12/ft_ft.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ft.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:38:58 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:40:37 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_ft(int *nbr) +{ + *nbr = 42; +} + +// #include + +// int main(void) +// { +// int nb; + +// ft_ft(&nb); +// printf("%d\n", nb); +// return (0); +// } \ No newline at end of file diff --git a/ex13/ft_swap.c b/ex13/ft_swap.c new file mode 100644 index 0000000..b13c050 --- /dev/null +++ b/ex13/ft_swap.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_swap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:41:12 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:43:40 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_swap(int *a, int *b) +{ + int tmp; + + tmp = *b; + *b = *a; + *a = tmp; +} + +// #include + +// int main(void) +// { +// int a = 10; +// int b = 20; + +// ft_swap(&a, &b); +// printf("a = %d, b = %d\n", a, b); +// return (0); +// } \ No newline at end of file diff --git a/ex14/ft_foreach.c b/ex14/ft_foreach.c new file mode 100644 index 0000000..c714ee2 --- /dev/null +++ b/ex14/ft_foreach.c @@ -0,0 +1,54 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_foreach.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:44:08 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:48:29 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_foreach(int *tab, int length, void (*f)(int)) +{ + int i; + + i = 0; + while (i < length) + { + f(tab[i]); + i++; + } +} + +// #include + +// void ft_putchar(char c) +// { +// write(1, &c, 1); +// } + +// void ft_putnbr(int nb) +// { +// if (nb == -2147483648) +// { +// write(1, "-2147483648", 11); +// return ; +// } +// if (nb < 0) +// { +// ft_putchar('-'); +// nb = -nb; +// } +// if (nb > 9) +// ft_putnbr(nb / 10); +// ft_putchar(nb % 10 + '0'); +// } + +// int main(void) +// { +// int tab[] = {1,2,3,4}; +// ft_foreach(tab, 4, &ft_putnbr); +// return (0); +// } \ No newline at end of file diff --git a/ex15/ft_print_param.c b/ex15/ft_print_param.c new file mode 100644 index 0000000..ae9ecd2 --- /dev/null +++ b/ex15/ft_print_param.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_param.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:49:03 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:52:50 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +void ft_putstr(char *str) +{ + int i; + + i = 0; + while (str[i]) + ft_putchar(str[i++]); +} + +int main(int ac, char **av) +{ + int i; + + i = 1; + (void)ac; + while (av[i]) + { + ft_putstr(av[i++]); + ft_putchar('\n'); + } + return (0); +} diff --git a/ex16/ft_main_printf.c b/ex16/ft_main_printf.c new file mode 100644 index 0000000..61a69d1 --- /dev/null +++ b/ex16/ft_main_printf.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_main_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:56:29 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:59:22 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +int mul2(int nb){return (nb * 2);} +char upper(char c){return (c - 32);} +char *add1(char str[]){int i = 0; while(str[i]){if (str[i] != 32){str[i] += 1;} i++;} return str;} +char *rm1(char str[]){int i = 0; while(str[i]){if (str[i] != 32){str[i] -= 1;} i++;} return str;} + +int main(void) +{ + int nb = '*'; + char c = 99; + char e = 33; + char str[] = "Gdkkn vnqkc"; + char str2[] = "(ftu"; + char d = 34; + int nbr = 43; + char str3[] = "Gdkqwe weqss !"; + char str4[] = "*fweeu"; + printf("%s %c %c%s %d\n", add1(str), e, c, rm1(str2), nb); + return (0); +} \ No newline at end of file diff --git a/ex2/ft_is_negative.c b/ex2/ft_is_negative.c new file mode 100644 index 0000000..01de7dc --- /dev/null +++ b/ex2/ft_is_negative.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_is_negative.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 22:48:11 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:12:21 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_is_negative(int n) +{ + if (n < 0) + write(1, "N", 1); + else + write(1, "P", 1); +} + +// int main(void) +// { +// ft_is_negative(-1); +// return (0); +// } \ No newline at end of file diff --git a/ex3/ft_iterative_power.c b/ex3/ft_iterative_power.c new file mode 100644 index 0000000..fc4c199 --- /dev/null +++ b/ex3/ft_iterative_power.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iterative_power.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 22:53:07 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:12:14 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_iterative_power(int nb, int power) +{ + int res; + + if (power < 0) + return (0); + if (power == 0 || nb == 0) + return (1); + res = nb; + while (power-- > 1) + res *= nb; + return (res); +} + +// #include +// int main(void) +// { +// printf("%d\n", ft_iterative_power(5, 5)); +// return (0); +// } \ No newline at end of file diff --git a/ex4/ft_recursive_power.c b/ex4/ft_recursive_power.c new file mode 100644 index 0000000..a225cd9 --- /dev/null +++ b/ex4/ft_recursive_power.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_power.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 22:59:09 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:12:08 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_recursive_power(int nb, int power) +{ + if (power < 0) + return (0); + else if (power == 0 || nb == 0) + return (1); + if (power != 1) + return (nb * ft_recursive_power(nb, power - 1)); + return (nb); +} + +// #include +// int main(void) +// { +// printf("%d\n", ft_recursive_power(5, 2)); +// return (0); +// } \ No newline at end of file diff --git a/ex5/ft_putnbr.c b/ex5/ft_putnbr.c new file mode 100644 index 0000000..9115fc1 --- /dev/null +++ b/ex5/ft_putnbr.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:03:38 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:12:01 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +void ft_putnbr(int nb) +{ + if (nb == -2147483648) + { + write(1, "-2147483648", 11); + return ; + } + if (nb < 0) + { + ft_putchar('-'); + nb = -nb; + } + if (nb > 9) + ft_putnbr(nb / 10); + ft_putchar(nb % 10 + '0'); +} + +// int main(void) +// { +// ft_putnbr(21474); +// return (0); +// } diff --git a/ex6/ft_putstr.c b/ex6/ft_putstr.c new file mode 100644 index 0000000..6f21228 --- /dev/null +++ b/ex6/ft_putstr.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:09:29 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:13:21 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +void ft_putstr(char *str) +{ + int i; + + i = 0; + while (str[i]) + ft_putchar(str[i++]); +} + +int main(void) +{ + ft_putstr(""); + return (0); +} diff --git a/ex7/ft_strlen.c b/ex7/ft_strlen.c new file mode 100644 index 0000000..7adac95 --- /dev/null +++ b/ex7/ft_strlen.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:13:42 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:15:58 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strlen(char *str) +{ + int i; + + i = 0; + while (str[i]) + i++; + return (i); +} + +// #include +// int main(void) +// { +// printf("%d", ft_strlen("1234567890")); +// return (0); +// } diff --git a/ex8/ft_str_is_alpha.c b/ex8/ft_str_is_alpha.c new file mode 100644 index 0000000..71b9dda --- /dev/null +++ b/ex8/ft_str_is_alpha.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_alpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:16:47 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:21:38 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_alpha(char *str) +{ + int i; + + i = 0; + while (str[i]) + { + if ((str[i] >= 'a' && str[i] <= 'z') + || (str[i] >= 'A' && str[i] <= 'Z')) + i++; + else + return (0); + } + return (1); +} + +// #include + +// int main(void) +// { +// printf("%d", ft_str_is_alpha("sd1asd")); +// return (0); +// } \ No newline at end of file diff --git a/ex9/ft_str_is_printable.c b/ex9/ft_str_is_printable.c new file mode 100644 index 0000000..bd3e2f6 --- /dev/null +++ b/ex9/ft_str_is_printable.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_str_is_printable.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sgongas +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/02/22 23:22:09 by sgongas #+# #+# */ +/* Updated: 2026/02/22 23:25:39 by sgongas ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_str_is_printable(char *str) +{ + int i; + + i = 0; + while (str[i]) + { + if (str[i] >= 32 && str[i] <= 126) + i++; + else + return (0); + } + return (1); +} + +// #include + +// int main(void) +// { +// printf("%d", ft_str_is_printable("test")); +// return (0); +// } +// "\x01" \ No newline at end of file