diff --git a/ex00/exo.tar b/ex00/exo.tar new file mode 100644 index 0000000..a843e50 Binary files /dev/null and b/ex00/exo.tar differ diff --git a/ex01/z b/ex01/z new file mode 100644 index 0000000..e900b1c --- /dev/null +++ b/ex01/z @@ -0,0 +1 @@ +Z diff --git a/ex02/clean b/ex02/clean new file mode 100644 index 0000000..da6d87b --- /dev/null +++ b/ex02/clean @@ -0,0 +1 @@ +find . -type f \( -name '*~' -o -name '#*# \) -print -delete \ No newline at end of file diff --git a/ex03/find_sh.sh b/ex03/find_sh.sh new file mode 100644 index 0000000..ee94708 --- /dev/null +++ b/ex03/find_sh.sh @@ -0,0 +1,2 @@ +#!/bin/sh +find . -type f -name "*.sh" -exec basename {} .sh \; \ No newline at end of file diff --git a/ex04/MAC.sh b/ex04/MAC.sh new file mode 100644 index 0000000..71d8bcb --- /dev/null +++ b/ex04/MAC.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ifconfig -a | grep ether | awk '{print $2}' \ No newline at end of file diff --git "a/ex05/\"\\?$*'MaRViN'*$?\\\"" "b/ex05/\"\\?$*'MaRViN'*$?\\\"" new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ "b/ex05/\"\\?$*'MaRViN'*$?\\\"" @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/ex06/ft_print_alphabet.c b/ex06/ft_print_alphabet.c new file mode 100644 index 0000000..7c75207 --- /dev/null +++ b/ex06/ft_print_alphabet.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_alphabet.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:11:05 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:11:13 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_putchar(char c); + +void ft_print_alphabet(void) +{ + char c; + + c = 96; + while (++c < 123) + ft_putchar(c); +} diff --git a/ex07/ft_print_numbers.c b/ex07/ft_print_numbers.c new file mode 100644 index 0000000..65e447e --- /dev/null +++ b/ex07/ft_print_numbers.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_numbers.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:12:28 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:12:40 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_putchar(char c); + +void ft_print_numbers(void) +{ + char c; + + c = 47; + while (++c < 58) + ft_putchar(c); +} diff --git a/ex08/ft_is_negative.c b/ex08/ft_is_negative.c new file mode 100644 index 0000000..189699a --- /dev/null +++ b/ex08/ft_is_negative.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_is_negative.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:14:15 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:14:34 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_putchar(char c); + +void ft_is_negative(int n) +{ + if (n >= 0) + ft_putchar('P'); + else + ft_putchar('N'); +} diff --git a/ex09/ft_ft.c b/ex09/ft_ft.c new file mode 100644 index 0000000..9fd90b7 --- /dev/null +++ b/ex09/ft_ft.c @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ft.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:15:27 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:15:46 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_ft(int *nbr) +{ + *nbr = 42; +} diff --git a/ex10/ft_swap.c b/ex10/ft_swap.c new file mode 100644 index 0000000..9314c55 --- /dev/null +++ b/ex10/ft_swap.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_swap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:16:35 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:16:49 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_swap(int *a, int *b) +{ + int swap; + + swap = *a; + *a = *b; + *b = swap; +} diff --git a/ex11/ft_div_mod.c b/ex11/ft_div_mod.c new file mode 100644 index 0000000..d6e877e --- /dev/null +++ b/ex11/ft_div_mod.c @@ -0,0 +1,17 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_div_mod.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:17:54 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:17:59 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_div_mod(int a, int b, int *div, int *mod) +{ + *div = a / b; + *mod = a % b; +} diff --git a/ex12/ft_iterative_factorial.c b/ex12/ft_iterative_factorial.c new file mode 100644 index 0000000..160ac90 --- /dev/null +++ b/ex12/ft_iterative_factorial.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iterative_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:18:58 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:19:27 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_iterative_factorial(int nb) +{ + int i; + int response; + + i = 1; + response = 1; + if (nb < 0 || nb > 12) + return (0); + if (nb == 0 || nb == 1) + return (1); + while (i <= nb) + { + response *= i; + i++; + } + return (response); +} diff --git a/ex13/ft_recursive_factorial.c b/ex13/ft_recursive_factorial.c new file mode 100644 index 0000000..f82ec0e --- /dev/null +++ b/ex13/ft_recursive_factorial.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_recursive_factorial.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:20:22 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:21:51 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_recursive_factorial(int nb) +{ + if (nb < 0 || nb > 12) + return (0); + else if (nb == 0 || nb == 1) + return (1); + else + return (nb * ft_recursive_factorial(nb - 1)); +} diff --git a/ex14/ft_sqrt.c b/ex14/ft_sqrt.c new file mode 100644 index 0000000..22803fe --- /dev/null +++ b/ex14/ft_sqrt.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sqrt.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:21:56 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:24:43 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_sqrt(int nb) +{ + int i; + + i = 1; + if (nb <= 0) + return (0); + while (i * i < nb) + { + i++; + if (i == 46340) + break ; + } + if (i * i == nb) + return (i); + return (0); +} diff --git a/ex15/ft_putstr.c b/ex15/ft_putstr.c new file mode 100644 index 0000000..c00c3db --- /dev/null +++ b/ex15/ft_putstr.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:25:59 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:26:19 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_putchar(char c); + +void ft_putstr(char *str) +{ + while (*str) + ft_putchar(*str++); +} diff --git a/ex16/ft_strlen.c b/ex16/ft_strlen.c new file mode 100644 index 0000000..4b84e4b --- /dev/null +++ b/ex16/ft_strlen.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:27:04 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:27:18 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strlen(char *str) +{ + int i; + + i = -1; + while (str[++i]) + ; + return (i--); +} diff --git a/ex17/ft_strcmp.c b/ex17/ft_strcmp.c new file mode 100644 index 0000000..8be3c3e --- /dev/null +++ b/ex17/ft_strcmp.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:28:07 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:28:27 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0') + i++; + return (s1[i] - s2[i]); +} diff --git a/ex18/ft_print_params.c b/ex18/ft_print_params.c new file mode 100644 index 0000000..1013e99 --- /dev/null +++ b/ex18/ft_print_params.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:29:11 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:29:27 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_putchar(char c); + +int main(int argc, char **argv) +{ + int i; + int j; + + i = 1; + if (argc < 1) + return (0); + while (i < argc) + { + j = 0; + while (argv[i][j] != '\0') + ft_putchar(argv[i][j++]); + ft_putchar('\n'); + i++; + } + return (0); +} diff --git a/ex19/ft_sort_params.c b/ex19/ft_sort_params.c new file mode 100644 index 0000000..1d40f32 --- /dev/null +++ b/ex19/ft_sort_params.c @@ -0,0 +1,65 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:30:02 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:30:57 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void ft_putchar(char c); + +void ft_putstr(char *str) +{ + while (*str) + ft_putchar(*str++); +} + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] == s2[i] && s1[i] != !0 && s2[i] != !0) + i++; + return (s1[i] - s2[i]); +} + +void ft_print_params(int argc, char **argv) +{ + int i; + + i = 1; + while (i < argc) + { + ft_putstr(argv[i++]); + ft_putchar('\n'); + } +} + +int main(int argc, char **argv) +{ + int i; + char *swap; + + i = 1; + if (argc > 1) + { + while (i < argc - 1) + { + if (ft_strcmp(argv[i], argv[i + 1]) > 0) + { + swap = argv[i]; + argv[i] = argv[i + 1]; + argv[i + 1] = swap; + i = 0; + } + i++; + } + ft_print_params(argc, argv); + } + return (0); +} diff --git a/ex20/ft_strdup.c b/ex20/ft_strdup.c new file mode 100644 index 0000000..8bc3ff5 --- /dev/null +++ b/ex20/ft_strdup.c @@ -0,0 +1,49 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:31:28 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:39:21 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +int ft_strlen(char *str) +{ + int i; + + i = -1; + while (str[++i]) + ; + return (i--); +} + +char *ft_strdup(char *src) +{ + int len; + int i; + char *ptr; + + if (src != NULL) + { + i = 0; + len = ft_strlen(src); + ptr = (char *) malloc (len *(sizeof(char))); + while (i <= len) + { + ptr[i] = src[i]; + i++; + } + ptr[i] = '\0'; + } + return (ptr); +} diff --git a/ex21/ft_range.c b/ex21/ft_range.c new file mode 100644 index 0000000..10d0a58 --- /dev/null +++ b/ex21/ft_range.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:32:40 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:33:00 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int *ft_range(int min, int max) +{ + int len; + int i; + int *ptr; + + if (min >= max) + return (ptr = NULL); + i = 0; + len = max - min; + ptr = (int *) malloc (len *(sizeof(int))); + while (min < max) + ptr[i++] = min++; + ptr[i] = '\0'; + return (ptr); +} diff --git a/ex22/ft_abs.h b/ex22/ft_abs.h new file mode 100644 index 0000000..b071eb1 --- /dev/null +++ b/ex22/ft_abs.h @@ -0,0 +1,13 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_abs.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:34:02 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:34:48 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +# define ABS(x) (x > 0 ? x : -x) \ No newline at end of file diff --git a/ex23/ft_point.h b/ex23/ft_point.h new file mode 100644 index 0000000..01b1a53 --- /dev/null +++ b/ex23/ft_point.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_point.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kechrist +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/04/03 23:35:21 by kechrist #+# #+# */ +/* Updated: 2022/04/03 23:35:34 by kechrist ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_POINT_H +# define FT_POINT_H + +typedef struct s_point +{ + int x; + int y; +} t_point; + +#endif \ No newline at end of file diff --git a/ex24/Makefile b/ex24/Makefile new file mode 100644 index 0000000..0ea0db9 --- /dev/null +++ b/ex24/Makefile @@ -0,0 +1,27 @@ +NAME = libft.a +CC = gcc +CFLAGS = -Wall -Werror -Wextra +SRCS_FILES = srcs/ft_putchar.c srcs/ft_putstr.c srcs/ft_strcmp.c \ + srcs/ft_strlen.c srcs/ft_swap.c +HEADER = ./includes/ +AR = ar rc +RM = rm -rf +OBJS = $(SRCS:srcs/%.c=%.o) + +all: $(NAME) + +$(NAME): $(OBJS) + $(AR) $(NAME) $(OBJS) + +$(OBJS): $(SRCS) + $(CC) $(CFLAGS) -c $(SRCS) -I $(HEADER) + +clean: + $(RM) $(OBJS) + +fclean: clean + $(RM) $(NAME) + +re: fclean all + +.PHONY: all clean fclean re \ No newline at end of file