├── C06 ├── ex00 │ └── .empty ├── ex03 │ └── run.sh ├── ex01 │ └── run.sh └── ex02 │ └── run.sh ├── C08 ├── ex04 │ ├── run.sh │ ├── ft_stock_str.h │ ├── main.c │ └── ft_show_tab.c ├── ex05 │ ├── run.sh │ ├── ft_stock_str.h │ ├── main.c │ └── ft_strs_to_tab.c ├── ex00 │ └── main.c ├── ex02 │ └── main.c ├── ex03 │ └── main.c └── ex01 │ └── main.c ├── C07 ├── ex03 │ ├── run.sh │ └── main.c ├── ex04 │ └── main.c ├── ex02 │ └── main.c ├── ex01 │ └── main.c ├── ex00 │ └── main.c └── ex05 │ └── main.c ├── C09 ├── ex00 │ └── run.sh ├── ex01 │ ├── srcs │ │ ├── ft_putstr.o │ │ ├── ft_strcmp.o │ │ ├── ft_strlen.o │ │ ├── ft_swap.o │ │ ├── ft_putchar.o │ │ ├── ft_putchar.c │ │ ├── ft_swap.c │ │ ├── ft_strlen.c │ │ ├── ft_strcmp.c │ │ └── ft_putstr.c │ ├── run.sh │ └── includes │ │ └── ft.h └── ex02 │ └── main.c ├── correct.sh ├── C00 ├── ex05 │ └── main.c ├── ex06 │ └── main.c ├── ex08 │ └── main.c ├── ex01 │ └── main.c ├── ex03 │ └── main.c ├── ex02 │ └── main.c ├── ex00 │ └── main.c ├── ex04 │ └── main.c └── ex07 │ └── main.c ├── C05 ├── ex08 │ └── main.c ├── ex04 │ └── main.c ├── ex05 │ └── main.c ├── ex00 │ └── main.c ├── ex01 │ └── main.c ├── ex02 │ └── main.c ├── ex03 │ └── main.c ├── ex06 │ └── main.c └── ex07 │ └── main.c ├── C04 ├── ex01 │ └── main.c ├── ex02 │ └── main.c ├── ex00 │ └── main.c ├── ex03 │ └── main.c ├── ex04 │ └── main.c └── ex05 │ └── main.c ├── C02 ├── ex12 │ └── main.c ├── ex00 │ └── main.c ├── ex06 │ └── main.c ├── ex07 │ └── main.c ├── ex08 │ └── main.c ├── ex02 │ └── main.c ├── ex03 │ └── main.c ├── ex11 │ └── main.c ├── ex09 │ └── main.c ├── ex01 │ └── main.c ├── ex04 │ └── main.c ├── ex05 │ └── main.c └── ex10 │ └── main.c ├── C01 ├── ex00 │ └── main.c ├── ex06 │ └── main.c ├── ex05 │ └── main.c ├── ex08 │ └── main.c ├── ex02 │ └── main.c ├── ex04 │ └── main.c ├── ex07 │ └── main.c ├── ex03 │ └── main.c └── ex01 │ └── main.c ├── C03 ├── ex00 │ └── main.c ├── ex02 │ └── main.c ├── ex04 │ └── main.c ├── ex01 │ └── main.c ├── ex03 │ └── main.c └── ex05 │ └── main.c └── README.md /C06/ex00/.empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /C08/ex04/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ex04/output Test 3 | -------------------------------------------------------------------------------- /C08/ex05/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ex05/output Test 3 | -------------------------------------------------------------------------------- /C06/ex03/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ex03/output "A" "Q" "B" "Z" "D" "0" 3 | -------------------------------------------------------------------------------- /C06/ex01/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ex01/output "S" "u" "c" "c" "e" "s" "s" 3 | -------------------------------------------------------------------------------- /C07/ex03/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ex03/output "said" "this" "is" "a" "success" 3 | -------------------------------------------------------------------------------- /C06/ex02/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./ex02/output "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" 3 | -------------------------------------------------------------------------------- /C09/ex00/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ex00 3 | sh libft_creator.sh 4 | 5 | ls -lR | grep libft 6 | -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_putstr.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Buom01/semi-auto-correct-42/HEAD/C09/ex01/srcs/ft_putstr.o -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_strcmp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Buom01/semi-auto-correct-42/HEAD/C09/ex01/srcs/ft_strcmp.o -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_strlen.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Buom01/semi-auto-correct-42/HEAD/C09/ex01/srcs/ft_strlen.o -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_swap.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Buom01/semi-auto-correct-42/HEAD/C09/ex01/srcs/ft_swap.o -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_putchar.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Buom01/semi-auto-correct-42/HEAD/C09/ex01/srcs/ft_putchar.o -------------------------------------------------------------------------------- /C09/ex01/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ex01 3 | make 4 | make clean 5 | make fclean 6 | make libft.a 7 | make fclean 8 | make all 9 | make re 10 | -------------------------------------------------------------------------------- /correct.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 4 | do 5 | echo "ex$i" 6 | ls -lRA eval/ex$i 7 | cp -R eval/ex$i/* ex$i/ 8 | norminette -R CheckForbiddenSourceHeader eval/ex$i/*.c eval/ex$i/*.h 9 | gcc -Wall -Wextra -Werror -o ex$i/output ex$i/*.c 10 | cat eval/ex$i/* 11 | read a 12 | if [ -f "./ex$i/run.sh" ]; then 13 | ./ex$i/run.sh 14 | else 15 | ./ex$i/output 16 | fi 17 | read a 18 | done 19 | -------------------------------------------------------------------------------- /C08/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/21 05:04:54 by badam #+# #+# */ 9 | /* Updated: 2019/06/21 05:05:05 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | int main(void) 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /C00/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:31:14 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_comb(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_comb(); 18 | } 19 | -------------------------------------------------------------------------------- /C00/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:31:51 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_comb2(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_comb2(); 18 | } 19 | -------------------------------------------------------------------------------- /C00/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:54:51 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_combn(int n); 14 | 15 | int main(void) 16 | { 17 | ft_print_combn(2); 18 | } 19 | -------------------------------------------------------------------------------- /C00/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:25:07 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_alphabet(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_alphabet(); 18 | } 19 | -------------------------------------------------------------------------------- /C00/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:24:43 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_numbers(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_numbers(); 18 | } 19 | -------------------------------------------------------------------------------- /C00/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:24:55 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_reverse_alphabet(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_reverse_alphabet(); 18 | } 19 | -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_putchar.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putchar.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/05 20:48:05 by badam #+# #+# */ 9 | /* Updated: 2019/06/23 04:36:31 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "ft.h" 15 | 16 | void ft_putchar(char c) 17 | { 18 | write(1, &c, 1); 19 | } 20 | -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_swap.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_swap.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 17:49:25 by badam #+# #+# */ 9 | /* Updated: 2019/06/23 04:40:01 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft.h" 14 | 15 | void ft_swap(int *a, int *b) 16 | { 17 | int c; 18 | 19 | c = *a; 20 | *a = *b; 21 | *b = c; 22 | } 23 | -------------------------------------------------------------------------------- /C08/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/21 05:09:14 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 03:49:19 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "ft_abs.h" 15 | 16 | int main(void) 17 | { 18 | printf("%d\n", ABS(-42)); 19 | printf("%d\n", ABS(42)); 20 | } 21 | -------------------------------------------------------------------------------- /C05/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/17 02:35:00 by badam #+# #+# */ 9 | /* Updated: 2019/06/17 02:36:59 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_ten_queens_puzzle(void); 16 | 17 | int main(void) 18 | { 19 | printf("\n%d solutions\n", ft_ten_queens_puzzle()); 20 | } 21 | -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_strlen.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strlen.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 03:14:44 by badam #+# #+# */ 9 | /* Updated: 2019/06/23 04:39:48 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft.h" 14 | 15 | int ft_strlen(char *str) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (str[i]) 21 | i++; 22 | return (i); 23 | } 24 | -------------------------------------------------------------------------------- /C04/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 15:51:06 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 15:54:02 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_putstr(char *str); 14 | 15 | int main(void) 16 | { 17 | char s1[] = "Suc"; 18 | char s2[] = "cess\n"; 19 | ft_putstr(s1); 20 | ft_putstr(s2); 21 | } 22 | -------------------------------------------------------------------------------- /C08/ex04/ft_stock_str.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_stock_str.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/22 21:35:09 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 21:35:47 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_STOCK_STR_H 14 | # define FT_STOCK_STR_H 15 | 16 | typedef struct s_stock_str 17 | { 18 | int size; 19 | char *str; 20 | char *copy; 21 | } t_stock_str; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /C08/ex05/ft_stock_str.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_stock_str.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/22 21:35:09 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 21:35:47 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_STOCK_STR_H 14 | # define FT_STOCK_STR_H 15 | 16 | typedef struct s_stock_str 17 | { 18 | int size; 19 | char *str; 20 | char *copy; 21 | } t_stock_str; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /C02/ex12/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:43:25 by badam #+# #+# */ 9 | /* Updated: 2019/06/11 16:20:43 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void *ft_print_memory(void *addr, unsigned int size); 14 | 15 | int main(void) 16 | { 17 | char str[] = "Ceci est un test d'affichage de print memory!\nSegFault"; 18 | ft_print_memory(str, 54); 19 | } 20 | -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_strcmp.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strcmp.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 23:19:59 by badam #+# #+# */ 9 | /* Updated: 2019/06/25 20:07:52 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft.h" 14 | 15 | int ft_strcmp(char *s1, char *s2) 16 | { 17 | int i; 18 | 19 | i = 0; 20 | while (s1[i] == s2[i] && s1[i] != 0) 21 | i++; 22 | return (s1[i] - s2[i]); 23 | } 24 | -------------------------------------------------------------------------------- /C08/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/22 21:28:03 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 21:34:21 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | struct s_stock_str *ft_strs_to_tab(int ac, char **av); 14 | void ft_show_tab(struct s_stock_str *par); 15 | 16 | int main(int argc, char **argv) 17 | { 18 | ft_show_tab(ft_strs_to_tab(argc, argv)); 19 | } 20 | -------------------------------------------------------------------------------- /C08/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/22 21:28:03 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 21:34:21 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | struct s_stock_str *ft_strs_to_tab(int ac, char **av); 14 | void ft_show_tab(struct s_stock_str *par); 15 | 16 | int main(int argc, char **argv) 17 | { 18 | ft_show_tab(ft_strs_to_tab(argc, argv)); 19 | } 20 | -------------------------------------------------------------------------------- /C09/ex01/srcs/ft_putstr.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_putstr.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 03:18:58 by badam #+# #+# */ 9 | /* Updated: 2019/06/23 04:36:41 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "ft.h" 15 | 16 | void ft_putstr(char *str) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (str[i]) 22 | { 23 | write(1, str + i, 1); 24 | i++; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /C08/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 21:28:21 by badam #+# #+# */ 9 | /* Updated: 2019/06/20 21:29:14 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft_point.h" 14 | void set_point(t_point *point) 15 | { 16 | point->x = 42; 17 | point->y = 21; 18 | } 19 | 20 | int main(void) 21 | { 22 | t_point point; 23 | set_point(&point); 24 | return (0); 25 | } 26 | -------------------------------------------------------------------------------- /C00/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:15:08 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:20:26 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_putchar(char c); 14 | 15 | int main(void) 16 | { 17 | ft_putchar('S'); 18 | ft_putchar('u'); 19 | ft_putchar('c'); 20 | ft_putchar('c'); 21 | ft_putchar('e'); 22 | ft_putchar('s'); 23 | ft_putchar('s'); 24 | } 25 | -------------------------------------------------------------------------------- /C09/ex01/includes/ft.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft.h :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/23 04:09:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/23 04:17:33 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #ifndef FT_H 14 | # define FT_H 15 | 16 | void ft_putchar(char c); 17 | void ft_swap(int *a, int *b); 18 | void ft_putstr(char *str); 19 | int ft_strlen(char *str); 20 | int ft_strcmp(char *s1, char *s2); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /C01/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:15:08 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 15:15:28 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_ft(int *nbr); 16 | 17 | int main(void) 18 | { 19 | int a = 3; 20 | ft_ft(&a); 21 | if (a == 42) 22 | { 23 | write(1, "OK\n", 3); 24 | } 25 | else 26 | { 27 | write(1, "FAIL\n", 5); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /C01/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/09 14:36:38 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 19:41:58 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *str); 16 | 17 | int main(void) 18 | { 19 | char str[] = "0123456789"; 20 | char str1[] = "test"; 21 | 22 | printf("10:%d\n", ft_strlen(str)); 23 | printf("4:%d\n", ft_strlen(str1)); 24 | } 25 | -------------------------------------------------------------------------------- /C07/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 02:30:20 by badam #+# #+# */ 9 | /* Updated: 2019/06/20 06:16:40 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strjoin(int size, char **strs, char *sep); 16 | 17 | int main(int argc, char **argv) 18 | { 19 | printf("./ex03/output___said___this___is___a___success :\n"); 20 | printf("%s\n", ft_strjoin(argc, argv, "___")); 21 | } 22 | -------------------------------------------------------------------------------- /C01/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/09 14:36:38 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 19:53:31 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putstr(char *str); 16 | 17 | int main(void) 18 | { 19 | char str[] = "0123456789"; 20 | char str1[] = "test"; 21 | 22 | printf("0123456789:\n"); 23 | ft_putstr(str); 24 | printf("\n\ntest:\n"); 25 | ft_putstr(str1); 26 | } 27 | -------------------------------------------------------------------------------- /C01/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/09 14:06:56 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 15:23:14 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_sort_int_tab(int *tab, int size); 16 | 17 | int main(void) 18 | { 19 | int c[5] = {55,-10,59,0,54}; 20 | ft_sort_int_tab(c, 5); 21 | printf("Ordre croissant:? "); 22 | printf("%d, %d, %d, %d, %d", c[0], c[1], c[2], c[3], c[4]); 23 | } 24 | -------------------------------------------------------------------------------- /C04/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 15:54:18 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 15:57:10 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putnbr(int nb); 16 | 17 | int main(void) 18 | { 19 | ft_putnbr(42); 20 | printf("\n"); 21 | ft_putnbr(-42); 22 | printf("\n"); 23 | ft_putnbr(-2147483648); 24 | printf("\n"); 25 | ft_putnbr(2147483647); 26 | printf("\n"); 27 | } 28 | -------------------------------------------------------------------------------- /C01/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:15:08 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 15:33:05 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_swap(int *a, int *b); 16 | 17 | int main(void) 18 | { 19 | int a = 3; 20 | int b = 18; 21 | ft_swap(&a, &b); 22 | if (b == 3 && a == 18) 23 | { 24 | write(1, "OK\n", 3); 25 | } 26 | else 27 | { 28 | write(1, "FAIL\n", 5); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /C07/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 03:29:23 by badam #+# #+# */ 9 | /* Updated: 2019/06/20 03:37:16 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_convert_base(char *nbr, char *base_from, char *base_to); 16 | 17 | int main(void) 18 | { 19 | printf("42:%s\n", ft_convert_base("--2a", "0123456789abcdef", "0123456789")); 20 | printf("-2a:%s\n", ft_convert_base("-42", "0123456789", "0123456789abcdef")); 21 | } 22 | -------------------------------------------------------------------------------- /C05/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:58:16 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 20:02:45 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_fibonacci(int index); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_fibonacci(0)); 20 | printf("1:%d\n", ft_fibonacci(1)); 21 | printf("1:%d\n", ft_fibonacci(2)); 22 | printf("2:%d\n", ft_fibonacci(3)); 23 | printf("55:%d\n", ft_fibonacci(10)); 24 | } 25 | -------------------------------------------------------------------------------- /C01/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:15:08 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 16:32:27 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_ultimate_div_mod(int *a, int *b); 16 | 17 | int main(void) 18 | { 19 | int a; 20 | int b; 21 | 22 | a = 16; 23 | b = 5; 24 | ft_ultimate_div_mod(&a, &b); 25 | if (a == 3 && b == 1) 26 | { 27 | write(1, "OK\n", 3); 28 | } 29 | else 30 | { 31 | write(1, "FAIL\n", 5); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /C02/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/11 20:40:53 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strcpy(char *dest, char *src); 16 | 17 | int main() 18 | { 19 | char dest[] = "Epic fail"; 20 | char src[] = "Success"; 21 | printf("Must all be same (3 lines):\n%s\n%s\n%s\n", src, ft_strcpy(dest, src), dest); 22 | char dest1[] = ""; 23 | char src1[] = ""; 24 | ft_strcpy(dest1, src1); 25 | } 26 | -------------------------------------------------------------------------------- /C01/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/09 14:36:38 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 16:37:04 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_rev_int_tab(int *tab, int size); 16 | 17 | int main(void) 18 | { 19 | int tab[10] = {0,1,2,3,4,5,6,7,8,9}; 20 | 21 | printf("9,8,7,6,5,4,3,2,1,0:"); 22 | ft_rev_int_tab(tab, 10); 23 | printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", tab[0], tab[1], tab[2], tab[3], tab[4], tab[5], tab[6], tab[7], tab[8], tab[9]); 24 | } 25 | -------------------------------------------------------------------------------- /C05/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 20:03:10 by badam #+# #+# */ 9 | /* Updated: 2019/06/17 04:48:51 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_sqrt(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("10:%d\n", ft_sqrt(100)); 20 | printf("6:%d\n", ft_sqrt(36)); 21 | printf("0:%d\n", ft_sqrt(37)); 22 | printf("100:%d\n", ft_sqrt(10000)); 23 | printf("0:%d\n", ft_sqrt(10001)); 24 | printf("2000:%d\n", ft_sqrt(4000000)); 25 | printf("0:%d\n", ft_sqrt(-36)); 26 | } 27 | -------------------------------------------------------------------------------- /C02/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 15:54:20 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_printable(char *src); 16 | 17 | int main() 18 | { 19 | char c; 20 | 21 | c = 1; 22 | while (c != 0) 23 | { 24 | if ((c < ' ' || c > '~') == ft_str_is_printable(&c)) 25 | { 26 | printf("Fail for char in decimal: %d\n", (int)c); 27 | return (0); 28 | } 29 | c++; 30 | } 31 | 32 | printf("Success\n"); 33 | } 34 | -------------------------------------------------------------------------------- /C01/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:15:08 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 16:13:40 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_div_mod(int a, int b, int *div, int *mod); 16 | 17 | int main(void) 18 | { 19 | int a; 20 | int b; 21 | int div; 22 | int mod; 23 | 24 | a = 16; 25 | b = 5; 26 | ft_div_mod(a, b, &div, &mod); 27 | if (div == 3 && mod == 1) 28 | { 29 | write(1, "OK\n", 3); 30 | } 31 | else 32 | { 33 | write(1, "FAIL\n", 5); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /C02/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/11 16:41:58 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strupcase(char *src); 16 | 17 | void ft_putstr(char *str) 18 | { 19 | int l; 20 | 21 | l = 0; 22 | while (str[l]) 23 | { 24 | l++; 25 | } 26 | write(1, str, l); 27 | } 28 | 29 | int main() 30 | { 31 | char c[] = "AbCdEfG-Yz"; 32 | ft_putstr("ABCDEFG-YZ:"); 33 | ft_putstr(ft_strupcase(c)); 34 | ft_putstr(":"); 35 | ft_putstr(c); 36 | } 37 | -------------------------------------------------------------------------------- /C02/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 22:01:37 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strlowcase(char *src); 16 | 17 | void ft_putstr(char *str) 18 | { 19 | int l; 20 | 21 | l = 0; 22 | while (str[l]) 23 | { 24 | l++; 25 | } 26 | write(1, str, l); 27 | } 28 | 29 | int main() 30 | { 31 | char c[] = "AbCdEfG-Yz"; 32 | ft_putstr("abcdefg-yz:"); 33 | ft_putstr(ft_strlowcase(c)); 34 | ft_putstr(":"); 35 | ft_putstr(c); 36 | } 37 | -------------------------------------------------------------------------------- /C05/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:50:42 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_iterative_factorial(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_iterative_factorial(-10)); 20 | printf("0:%d\n", ft_iterative_factorial(-1)); 21 | printf("1:%d\n", ft_iterative_factorial(0)); 22 | printf("1:%d\n", ft_iterative_factorial(1)); 23 | printf("3628800:%d\n", ft_iterative_factorial(10)); 24 | printf("6:%d\n", ft_iterative_factorial(3)); 25 | } 26 | -------------------------------------------------------------------------------- /C05/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:52:32 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_recursive_factorial(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_recursive_factorial(-10)); 20 | printf("0:%d\n", ft_recursive_factorial(-1)); 21 | printf("1:%d\n", ft_recursive_factorial(0)); 22 | printf("1:%d\n", ft_recursive_factorial(1)); 23 | printf("3628800:%d\n", ft_recursive_factorial(10)); 24 | printf("6:%d\n", ft_recursive_factorial(3)); 25 | } 26 | -------------------------------------------------------------------------------- /C05/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:55:24 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_iterative_power(int nb, int power); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_iterative_power(1, -10)); 20 | printf("0:%d\n", ft_iterative_power(1, -1)); 21 | printf("1:%d\n", ft_iterative_power(10, 0)); 22 | printf("10:%d\n", ft_iterative_power(10, 1)); 23 | printf("100:%d\n", ft_iterative_power(10, 2)); 24 | printf("216:%d\n", ft_iterative_power(6, 3)); 25 | } 26 | -------------------------------------------------------------------------------- /C05/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:56:03 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_recursive_power(int nb, int power); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_recursive_power(1, -10)); 20 | printf("0:%d\n", ft_recursive_power(1, -1)); 21 | printf("1:%d\n", ft_recursive_power(10, 0)); 22 | printf("10:%d\n", ft_recursive_power(10, 1)); 23 | printf("100:%d\n", ft_recursive_power(10, 2)); 24 | printf("216:%d\n", ft_recursive_power(6, 3)); 25 | } 26 | -------------------------------------------------------------------------------- /C02/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 15:35:51 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_str_is_alpha(char *src); 16 | 17 | int main() 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_str_is_alpha("")?"OK":"Fail", 21 | ft_str_is_alpha("ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz")?"OK":"Fail", 22 | !ft_str_is_alpha("1")?"OK":"Fail", 23 | !ft_str_is_alpha(" ")?"OK":"Fail", 24 | !ft_str_is_alpha("\\")?"OK":"Fail", 25 | !ft_str_is_alpha("\n")?"OK":"Fail"); 26 | } 27 | -------------------------------------------------------------------------------- /C08/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 21:15:11 by badam #+# #+# */ 9 | /* Updated: 2019/06/20 21:15:56 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include "ft_boolean.h" 14 | #include 15 | 16 | void ft_putstr(char *str) 17 | { 18 | while (*str) 19 | write(1, str++, 1); 20 | } 21 | 22 | t_bool ft_is_even(int nbr) 23 | { 24 | return ((EVEN(nbr)) ? TRUE : FALSE); 25 | } 26 | 27 | int main(int argc, char **argv) 28 | { 29 | (void)argv; 30 | if (ft_is_even(argc - 1) == TRUE) 31 | ft_putstr(EVEN_MSG); 32 | else 33 | ft_putstr(ODD_MSG); 34 | return (SUCCESS); 35 | } 36 | -------------------------------------------------------------------------------- /C02/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 15:38:49 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_str_is_numeric(char *src); 16 | 17 | int main() 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_str_is_numeric("")?"OK":"Fail", 21 | !ft_str_is_numeric("ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz")?"OK":"Fail", 22 | ft_str_is_numeric("0123456789")?"OK":"Fail", 23 | !ft_str_is_numeric(" ")?"OK":"Fail", 24 | !ft_str_is_numeric("\\")?"OK":"Fail", 25 | !ft_str_is_numeric("\n")?"OK":"Fail"); 26 | } 27 | -------------------------------------------------------------------------------- /C02/ex11/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/11 23:01:50 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_putstr_non_printable(char *src); 16 | 17 | void ft_putstr(char *str) 18 | { 19 | int l; 20 | 21 | l = 0; 22 | while (str[l]) 23 | { 24 | l++; 25 | } 26 | write(1, str, l); 27 | } 28 | 29 | int main() 30 | { 31 | char c[] = "Coucou\ntu vas bien ?"; 32 | ft_putstr("Coucou\\0atu vas bien ?:"); 33 | ft_putstr_non_printable(c); 34 | char d[] = "\x81\xbe"; 35 | ft_putstr("\n\\81\\be:"); 36 | ft_putstr_non_printable(d); 37 | } 38 | -------------------------------------------------------------------------------- /C01/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:15:08 by badam #+# #+# */ 9 | /* Updated: 2019/06/09 16:06:13 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_ultimate_ft(int *********nbr); 16 | 17 | int main(void) 18 | { 19 | int a, *b, **c, ***d, ****e, *****f, ******g, *******h, ********i, *********j; 20 | 21 | 22 | j = &i; 23 | i = &h; 24 | h = &g; 25 | g = &f; 26 | f = &e; 27 | e = &d; 28 | d = &c; 29 | c = &b; 30 | b = &a; 31 | 32 | ft_ultimate_ft(j); 33 | if (a == 42) 34 | { 35 | write(1, "OK\n", 3); 36 | } 37 | else 38 | { 39 | write(1, "FAIL\n", 5); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /C02/ex09/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 22:05:50 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strcapitalize(char *src); 16 | 17 | void ft_putstr(char *str) 18 | { 19 | int l; 20 | 21 | l = 0; 22 | while (str[l]) 23 | { 24 | l++; 25 | } 26 | write(1, str, l); 27 | } 28 | 29 | int main() 30 | { 31 | char c[] = "salut, coMMent tu vAs ? 42mOts quArAnTe-dEux; cinQuante+et+un"; 32 | ft_putstr("Salut, Comment Tu Vas ? 42mots Quarante-Deux; Cinquante+Et+Un:"); 33 | ft_putstr(ft_strcapitalize(c)); 34 | ft_putstr(":"); 35 | ft_putstr(c); 36 | } 37 | -------------------------------------------------------------------------------- /C03/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/12 09:18:40 by badam #+# #+# */ 9 | /* Updated: 2019/06/12 19:58:01 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strcmp(char *s1, char *s2); 17 | 18 | int main(void) 19 | { 20 | char s1[] = "Test1"; 21 | char s2[] = "OK"; 22 | char s3[] = "Same"; 23 | char s4[] = "Size"; 24 | char s5[] = "Shorter"; 25 | char s6[] = "ThanMyself"; 26 | 27 | printf("%d, %d\n", ft_strcmp(s1, s2), strcmp(s1, s2)); 28 | printf("%d, %d\n", ft_strcmp(s3, s4), strcmp(s3, s4)); 29 | printf("%d, %d\n", ft_strcmp(s5, s6), strcmp(s5, s6)); 30 | printf("%d, %d\n", ft_strcmp(s5, s5), strcmp(s5, s5)); 31 | } 32 | -------------------------------------------------------------------------------- /C02/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/12 00:07:37 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_strncpy(char *dest, char *src, unsigned int n); 16 | 17 | int main() 18 | { 19 | int i; 20 | char dest[] = "Epic fail !!!!!"; 21 | char src[] = "Success"; 22 | printf("%s\n%s\n%s\n", src, ft_strncpy(dest, src, 15), dest); 23 | i = 9; 24 | while (i < 15) 25 | { 26 | if (dest[i] != '\0') 27 | { 28 | printf("FAIL! Remainder of dst must be filled with `\\0' characters, got %c (\\%x) at pos %d\n", dest[i], dest[i], i); 29 | return (1); 30 | } 31 | i++; 32 | } 33 | return (0); 34 | } 35 | -------------------------------------------------------------------------------- /C04/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 15:45:22 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 15:50:29 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *str); 16 | 17 | int main(void) 18 | { 19 | char s1[] = "MyStr"; 20 | char s2[] = "MyTest\nOfSuccess"; 21 | char s3[] = "0123456789abcdef"; 22 | char s4[] = "My\tStr"; 23 | char s5[] = ""; 24 | printf(ft_strlen(s1) == 5 ? "Success\n" : "Fail\n"); 25 | printf(ft_strlen(s2) == 16 ? "Success\n" : "Fail\n"); 26 | printf(ft_strlen(s3) == 16 ? "Success\n" : "Fail\n"); 27 | printf(ft_strlen(s4) == 6 ? "Success\n" : "Fail\n"); 28 | printf(ft_strlen(s5) == 0 ? "Success\n" : "Fail\n"); 29 | } 30 | -------------------------------------------------------------------------------- /C04/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 15:54:18 by badam #+# #+# */ 9 | /* Updated: 2019/06/14 10:33:27 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_atoi(char *str); 16 | 17 | int main(void) 18 | { 19 | printf("42:%d\n", ft_atoi(" \n 42t4457")); 20 | printf("-42:%d\n", ft_atoi(" --+-42sfs:f545")); 21 | printf("0:%d\n", ft_atoi("\0 1337")); 22 | printf("0:%d\n", ft_atoi("-0")); 23 | printf("0:%d\n", ft_atoi(" - 1 3 2 5 6 3 2 1 6 7")); 24 | printf("-1325632167:%d\n", ft_atoi("-1325632167")); 25 | printf("-100:%d\n", ft_atoi("-100")); 26 | printf("min:%d\n", ft_atoi("\t---+2147483648")); 27 | printf("max:%d\n", ft_atoi("\v2147483647")); 28 | } 29 | -------------------------------------------------------------------------------- /C02/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 15:40:29 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_str_is_lowercase(char *src); 16 | 17 | int main() 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_str_is_lowercase("")?"OK":"Fail", 21 | ft_str_is_lowercase("abcdefghijklmnopqrstuvwxyz")?"OK":"Fail", 22 | !ft_str_is_lowercase("ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz")?"OK":"Fail", 23 | !ft_str_is_lowercase("0123456789")?"OK":"Fail", 24 | !ft_str_is_lowercase(" ")?"OK":"Fail", 25 | !ft_str_is_lowercase("\\")?"OK":"Fail", 26 | !ft_str_is_lowercase("\n")?"OK":"Fail"); 27 | } 28 | -------------------------------------------------------------------------------- /C02/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/10 14:59:19 by badam #+# #+# */ 9 | /* Updated: 2019/06/10 15:43:05 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | char *ft_str_is_uppercase(char *src); 16 | 17 | int main() 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_str_is_uppercase("")?"OK":"Fail", 21 | ft_str_is_uppercase("ABCDEFGHIJKLMNOPQRSTUVWXZ")?"OK":"Fail", 22 | !ft_str_is_uppercase("ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz")?"OK":"Fail", 23 | !ft_str_is_uppercase("0123456789")?"OK":"Fail", 24 | !ft_str_is_uppercase(" ")?"OK":"Fail", 25 | !ft_str_is_uppercase("\\")?"OK":"Fail", 26 | !ft_str_is_uppercase("\n")?"OK":"Fail"); 27 | } 28 | -------------------------------------------------------------------------------- /C00/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 20:59:32 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_is_negative(int n); 16 | 17 | int main(void) 18 | { 19 | write(1, "P:", 2); 20 | ft_is_negative(1); 21 | write(1, "\n", 1); 22 | write(1, "P:", 2); 23 | ft_is_negative(0); 24 | write(1, "\n", 1); 25 | write(1, "P:", 2); 26 | ft_is_negative(2147483647); 27 | write(1, "\n", 1); 28 | 29 | write(1, "N:", 2); 30 | ft_is_negative(-1); 31 | write(1, "\n", 1); 32 | write(1, "N:", 2); 33 | ft_is_negative(-15); 34 | write(1, "\n", 1); 35 | write(1, "N:", 2); 36 | ft_is_negative(-2147483648); 37 | write(1, "\n", 1); 38 | } 39 | -------------------------------------------------------------------------------- /C07/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 01:09:37 by badam #+# #+# */ 9 | /* Updated: 2019/06/20 02:48:47 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_ultimate_range(int **range, int min, int max); 16 | 17 | int main(void) 18 | { 19 | int *range; 20 | 21 | printf("Warn: Any segfault will mean that arrays are not correctly allocated\n"); 22 | 23 | printf("5:%d\n", ft_ultimate_range(&range, 0, 5)); 24 | printf("0, 1, 2, 3, 4 : %d, %d, %d, %d, %d\n", range[0], range[1], range[2], range[3], range[4]); 25 | 26 | printf("0:%d\n", ft_ultimate_range(&range, 3, 3)); 27 | 28 | printf("2:%d\n", ft_ultimate_range(&range, -1, 1)); 29 | printf("-1, 0 : %d, %d", range[0], range[1]); 30 | } 31 | -------------------------------------------------------------------------------- /C04/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 17:06:42 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 18:32:22 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putnbr_base(int nbr, char *base); 16 | 17 | int main(void) 18 | { 19 | write(1, "42:", 3); 20 | ft_putnbr_base(42, "0123456789"); 21 | write(1, "\n2a:", 4); 22 | ft_putnbr_base(42, "0123456789abcdef"); 23 | write(1, "\n-2a:", 5); 24 | ft_putnbr_base(-42, "0123456789abcdef"); 25 | write(1, "\n:", 2); 26 | ft_putnbr_base(42, ""); 27 | write(1, "\n:", 2); 28 | ft_putnbr_base(42, "0"); 29 | write(1, "\n:", 2); 30 | ft_putnbr_base(42, "+-0123456789abcdef"); 31 | write(1, "\n:", 2); 32 | ft_putnbr_base(42, "\t0123456789abcdef"); 33 | } 34 | -------------------------------------------------------------------------------- /C07/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 01:09:37 by badam #+# #+# */ 9 | /* Updated: 2019/06/20 01:54:46 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int *ft_range(int min, int max); 16 | 17 | int main(void) 18 | { 19 | int *range; 20 | 21 | printf("Warn: Don't forget to check that the array is of the correct size manually ! Can't know size of `malloc` arrays\n"); 22 | printf("Warn: Any segfault will mean that arrays are not correctly allocated\n"); 23 | 24 | range = ft_range(0, 5); 25 | printf("0, 1, 2, 3, 4 : %d, %d, %d, %d, %d\n", range[0], range[1], range[2], range[3], range[4]); 26 | 27 | range = ft_range(3, 3); 28 | 29 | range = ft_range(-1, 1); 30 | printf("-1, 0 : %d, %d", range[0], range[1]); 31 | } 32 | -------------------------------------------------------------------------------- /C00/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/08 20:19:12 by badam #+# #+# */ 9 | /* Updated: 2019/06/08 21:20:06 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_putnbr(int nb); 16 | 17 | int main(void) 18 | { 19 | write(1, "42:", 3); 20 | ft_putnbr(42); 21 | write(1, "\n", 1); 22 | write(1, "10:", 3); 23 | ft_putnbr(10); 24 | write(1, "\n", 1); 25 | write(1, "0:", 2); 26 | ft_putnbr(0); 27 | write(1, "\n", 1); 28 | 29 | write(1, "-42:", 4); 30 | ft_putnbr(-42); 31 | write(1, "\n", 1); 32 | write(1, "-1:", 3); 33 | ft_putnbr(-1); 34 | write(1, "\n", 1); 35 | write(1, "max:", 4); 36 | ft_putnbr(2147483647); 37 | write(1, "\n", 1); 38 | write(1, "min:", 4); 39 | ft_putnbr(-2147483648); 40 | write(1, "\n", 1); 41 | } 42 | -------------------------------------------------------------------------------- /C04/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/13 17:38:38 by badam #+# #+# */ 9 | /* Updated: 2019/06/17 17:35:36 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_atoi_base(char *str, char *base); 16 | 17 | int main(void) 18 | { 19 | printf("42:%d\n", ft_atoi_base("2a", "0123456789abcdef")); 20 | printf("-42:%d\n", ft_atoi_base(" --------+-2a", "0123456789abcdef")); 21 | printf("42:%d\n", ft_atoi_base(" -+-2a", "0123456789abcdef")); 22 | printf("0:%d\n", ft_atoi_base(" --------+- 2a", "0123456789abcdef")); 23 | printf("0:%d\n", ft_atoi_base(" --------+-z", "0123456789abcdef")); 24 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "")); 25 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "0")); 26 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "+-0")); 27 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "\t01")); 28 | } 29 | -------------------------------------------------------------------------------- /C05/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 20:36:43 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 20:43:20 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_is_prime(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_is_prime(-1) == 0 ? "OK" : "Fail", 21 | ft_is_prime(-3) == 0 ? "OK" : "Fail", 22 | ft_is_prime(0) == 0 ? "OK" : "Fail", 23 | ft_is_prime(1) == 0 ? "OK" : "Fail", 24 | ft_is_prime(2) == 1 ? "OK" : "Fail", 25 | ft_is_prime(3) == 1 ? "OK" : "Fail", 26 | ft_is_prime(4) == 0 ? "OK" : "Fail", 27 | ft_is_prime(5) == 1 ? "OK" : "Fail", 28 | ft_is_prime(6) == 0 ? "OK" : "Fail", 29 | ft_is_prime(7) == 1 ? "OK" : "Fail", 30 | ft_is_prime(10) == 0 ? "OK" : "Fail", 31 | ft_is_prime(11) == 1 ? "OK" : "Fail", 32 | ft_is_prime(13) == 1 ? "OK" : "Fail", 33 | ft_is_prime(19) == 1 ? "OK" : "Fail", 34 | ft_is_prime(20) == 0 ? "OK" : "Fail" 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /C08/ex05/ft_strs_to_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_strs_to_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/21 02:41:44 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 04:11:58 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "ft_stock_str.h" 15 | 16 | int ft_strlen(char *str) 17 | { 18 | int i; 19 | 20 | i = 0; 21 | while (str[i]) 22 | i++; 23 | return (i); 24 | } 25 | 26 | char *ft_strcpy(char *dest, char *src) 27 | { 28 | int i; 29 | 30 | i = 0; 31 | while (src[i]) 32 | { 33 | dest[i] = src[i]; 34 | i++; 35 | } 36 | dest[i] = '\0'; 37 | return (dest); 38 | } 39 | 40 | struct s_stock_str *ft_strs_to_tab(int ac, char **av) 41 | { 42 | t_stock_str *r; 43 | int i; 44 | 45 | r = malloc(sizeof(t_stock_str) * (ac + 1)); 46 | if (r == 0) 47 | return (0); 48 | i = 0; 49 | while (i < ac) 50 | { 51 | r[i].size = ft_strlen(av[i]); 52 | r[i].str = av[i]; 53 | r[i].copy = malloc(sizeof(char) * (r[i].size + 1)); 54 | if (r[i].copy == 0) 55 | return (0); 56 | ft_strcpy(r[i].copy, av[i]); 57 | i++; 58 | } 59 | r[i].str = 0; 60 | return (r); 61 | } 62 | -------------------------------------------------------------------------------- /C03/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/12 09:18:40 by badam #+# #+# */ 9 | /* Updated: 2019/06/12 22:05:51 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strcat(char *dest, char *src); 17 | 18 | int main(void) 19 | { 20 | char s1a[10] = "Test1"; 21 | char s2a[] = "OK"; 22 | char s1b[10] = "Test1"; 23 | char s2b[] = "OK"; 24 | char s3a[10] = "Same"; 25 | char s4a[] = "Size"; 26 | char s3b[10] = "Same"; 27 | char s4b[] = "Size"; 28 | char s5a[20] = "Shorter"; 29 | char s6a[] = "ThanMyself"; 30 | char s5b[20] = "Shorter"; 31 | char s6b[] = "ThanMyself"; 32 | 33 | printf("%s:%s\n", ft_strcat(s1a, s2a), strcat(s1b, s2b)); 34 | printf("%s\n", strcmp(s1a, s1b) == 0 && strcmp(s2a, s2b) == 0 ? "Success" : "Fail"); 35 | printf("%s:%s\n", ft_strcat(s3a, s4a), strcat(s3b, s4b)); 36 | printf("%s\n", strcmp(s3a, s3b) == 0 && strcmp(s4a, s4b) == 0 ? "Success" : "Fail"); 37 | printf("%s:%s\n", ft_strcat(s5a, s6a), strcat(s5b, s6b)); 38 | printf("%s\n", strcmp(s5a, s5b) == 0 && strcmp(s6a, s6b) == 0 ? "Success" : "Fail"); 39 | } 40 | -------------------------------------------------------------------------------- /C03/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/12 09:18:40 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 10:23:43 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strstr(char *str, char *to_find); 17 | 18 | 19 | int main(void) 20 | { 21 | char s1a[] = "This is OK for now"; 22 | char s2a[] = "OK"; 23 | char s1b[] = "This is OK for now"; 24 | char s2b[] = "OK"; 25 | char s3a[] = "Same"; 26 | char s4a[] = ""; 27 | char s3b[] = "Same"; 28 | char s4b[] = ""; 29 | char s5a[] = "Shorter"; 30 | char s6a[] = "Than"; 31 | char s5b[] = "Shorter"; 32 | char s6b[] = "Than"; 33 | 34 | printf("%s:%s\n", ft_strstr(s1a, s2a), strstr(s1b, s2b)); 35 | printf("%s\n", strcmp(s1a, s1b) == 0 && strcmp(s2a, s2b) == 0 ? "Success" : "Fail"); 36 | printf("%s:%s\n", ft_strstr(s3a, s4a), strstr(s3b, s4b)); 37 | printf("%s\n", strcmp(s3a, s3b) == 0 && strcmp(s4a, s4b) == 0 ? "Success" : "Fail"); 38 | printf("%s:%s\n", ft_strstr(s5a, s6a), strstr(s5b, s6b)); 39 | printf("%s\n", strcmp(s5a, s5b) == 0 && strcmp(s6a, s6b) == 0 ? "Success" : "Fail"); 40 | } 41 | -------------------------------------------------------------------------------- /C05/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 20:36:43 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 20:51:23 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_find_next_prime(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_find_next_prime(-1) == 2 ? "OK" : "Fail", 21 | ft_find_next_prime(-3) == 2 ? "OK" : "Fail", 22 | ft_find_next_prime(0) == 2 ? "OK" : "Fail", 23 | ft_find_next_prime(1) == 2 ? "OK" : "Fail", 24 | ft_find_next_prime(2) == 2 ? "OK" : "Fail", 25 | ft_find_next_prime(3) == 3 ? "OK" : "Fail", 26 | ft_find_next_prime(4) == 5 ? "OK" : "Fail", 27 | ft_find_next_prime(5) == 5 ? "OK" : "Fail", 28 | ft_find_next_prime(6) == 7 ? "OK" : "Fail", 29 | ft_find_next_prime(7) == 7 ? "OK" : "Fail", 30 | ft_find_next_prime(10) == 11 ? "OK" : "Fail", 31 | ft_find_next_prime(11) == 11 ? "OK" : "Fail", 32 | ft_find_next_prime(13) == 13 ? "OK" : "Fail", 33 | ft_find_next_prime(19) == 19 ? "OK" : "Fail", 34 | ft_find_next_prime(20) == 23 ? "OK" : "Fail" 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /C03/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/12 09:18:40 by badam #+# #+# */ 9 | /* Updated: 2019/06/12 20:10:17 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strncmp(char *s1, char *s2, unsigned int n); 17 | 18 | int main(void) 19 | { 20 | char s1[] = "Test1"; 21 | char s2[] = "OK"; 22 | char s3[] = "Same"; 23 | char s4[] = "Size"; 24 | char s5[] = "Shorter"; 25 | char s6[] = "ThanMyself"; 26 | char s7[] = "ShorterTest"; 27 | 28 | printf("%d, %d\n", ft_strncmp(s1, s2, 4), strncmp(s1, s2, 4)); 29 | printf("%d, %d\n", ft_strncmp(s1, s2, 2), strncmp(s1, s2, 2)); 30 | printf("%d, %d\n", ft_strncmp(s3, s4, 4), strncmp(s3, s4, 4)); 31 | printf("%d, %d\n", ft_strncmp(s3, s4, 1), strncmp(s3, s4, 1)); 32 | printf("%d, %d\n", ft_strncmp(s5, s6, 3), strncmp(s5, s6, 3)); 33 | printf("%d, %d\n", ft_strncmp(s5, s5, 10), strncmp(s5, s5, 10)); 34 | printf("%d, %d\n", ft_strncmp(s5, s5, 5), strncmp(s5, s5, 5)); 35 | printf("%d, %d\n", ft_strncmp(s5, s7, 7), strncmp(s5, s7, 7)); 36 | printf("%d, %d\n", ft_strncmp(s5, s7, 8), strncmp(s5, s7, 8)); 37 | } 38 | -------------------------------------------------------------------------------- /C07/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/19 22:00:04 by badam #+# #+# */ 9 | /* Updated: 2019/06/19 22:11:56 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strdup(char *src); 17 | 18 | int main(void) 19 | { 20 | printf("%s\n", strcmp(strdup("Test"), ft_strdup("Test")) == 0 ? 21 | "OK" : 22 | "Fail"); 23 | printf("%s\n", strcmp(strdup("484df41hdy1h111fs1fsd15sf15sdf115d15fdgs15gfd4sg1615df156g1515g4erg4561esg156gr15156g15eg15eg15e51e51g1515ge156e156eg156e15156ge516e1551eg51eg15g1551eg15e516eg15e15eg1515e55eg51e15e51g5151eg15eg1515egr515151erg51er51e51e551ee5eg51egr51er51er5er5eg51e5r1e51rg5egr5eg51erg5e1r51e6rg51egr516ee5g15e1g5e1g5e1g51ger51egr51erg55reg5er55er55"), ft_strdup("484df41hdy1h111fs1fsd15sf15sdf115d15fdgs15gfd4sg1615df156g1515g4erg4561esg156gr15156g15eg15eg15e51e51g1515ge156e156eg156e15156ge516e1551eg51eg15g1551eg15e516eg15e15eg1515e55eg51e15e51g5151eg15eg1515egr515151erg51er51e51e551ee5eg51egr51er51er5er5eg51e5r1e51rg5egr5eg51erg5e1r51e6rg51egr516ee5g15e1g5e1g5e1g51ger51egr51erg55reg5er55er55")) == 0 ? 24 | "OK" : 25 | "Fail"); 26 | } 27 | -------------------------------------------------------------------------------- /C03/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/12 09:18:40 by badam #+# #+# */ 9 | /* Updated: 2019/06/12 22:48:45 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strncat(char *dest, char *src, unsigned int nb); 17 | 18 | int main(void) 19 | { 20 | char s1a[10] = "Test1"; 21 | char s2a[] = "OK"; 22 | char s1b[10] = "Test1"; 23 | char s2b[] = "OK"; 24 | char s3a[10] = "Same"; 25 | char s4a[10] = "Size"; 26 | char s3b[10] = "Same"; 27 | char s4b[10] = "Size"; 28 | char s5a[20] = "Shorter"; 29 | char s6a[] = "ThanMyself"; 30 | char s5b[20] = "Shorter"; 31 | char s6b[] = "ThanMyself"; 32 | 33 | printf("%s:%s\n", ft_strncat(s1a, s2a, 5), strncat(s1b, s2b, 5)); 34 | printf("%s\n", strcmp(s1a, s1b) == 0 && strcmp(s2a, s2b) == 0 ? "Success" : "Fail"); 35 | printf("%s:%s\n", ft_strncat(s3a, s4a, 10), strncat(s3b, s4b, 10)); 36 | printf("%s\n", strcmp(s3a, s3b) == 0 && strcmp(s4a, s4b) == 0 ? "Success" : "Fail"); 37 | printf("%s:%s\n", ft_strncat(s5a, s6a, 0), strncat(s5b, s6b, 0)); 38 | printf("%s\n", strcmp(s5a, s5b) == 0 && strcmp(s6a, s6b) == 0 ? "Success" : "Fail"); 39 | } 40 | -------------------------------------------------------------------------------- /C08/ex04/ft_show_tab.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ft_show_tab.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/21 04:21:46 by badam #+# #+# */ 9 | /* Updated: 2019/06/22 04:11:02 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include "ft_stock_str.h" 15 | 16 | struct s_stock_str *ft_strs_to_tab(int ac, char **av); 17 | 18 | void ft_putnbr(int nb) 19 | { 20 | long size; 21 | char c; 22 | 23 | size = 1; 24 | if (nb < 0) 25 | { 26 | if (nb == -2147483648) 27 | { 28 | write(1, "-2147483648", 11); 29 | return ; 30 | } 31 | nb *= -1; 32 | write(1, "-", 1); 33 | } 34 | while (nb / size > 9) 35 | size *= 10; 36 | while (size > 0) 37 | { 38 | c = '0' + ((nb / size) - (nb / (size * 10)) * 10); 39 | write(1, &c, 1); 40 | size /= 10; 41 | } 42 | } 43 | 44 | void ft_putstr(char *str) 45 | { 46 | int i; 47 | 48 | i = 0; 49 | while (str[i]) 50 | { 51 | write(1, str + i, 1); 52 | i++; 53 | } 54 | } 55 | 56 | void ft_show_tab(struct s_stock_str *par) 57 | { 58 | int i; 59 | 60 | i = 0; 61 | while (par[i].str) 62 | { 63 | ft_putstr(par[i].str); 64 | ft_putstr("\n"); 65 | ft_putnbr(par[i].size); 66 | ft_putstr("\n"); 67 | ft_putstr(par[i].copy); 68 | ft_putstr("\n"); 69 | i++; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /C02/ex10/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/11 14:14:49 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 00:01:32 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | unsigned int ft_strlcpy(char *dest, char *src, unsigned int size); 17 | 18 | int main(void) 19 | { 20 | char src1a[] = "abcde"; 21 | char dest1a[] = "1234567"; 22 | char src1b[] = "abcde"; 23 | char dest1b[] = "1234567"; 24 | char src2a[] = "abcd"; 25 | char dest2a[] = "123"; 26 | char src2b[] = "abcd"; 27 | char dest2b[] = "123"; 28 | char src3a[] = ""; 29 | char dest3a[] = ""; 30 | char src3b[] = ""; 31 | char dest3b[] = ""; 32 | char src4a[] = "12345"; 33 | char dest4a[] = "abc"; 34 | char src4b[] = "12345"; 35 | char dest4b[] = "abc"; 36 | 37 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 38 | ft_strlcpy(dest1a, src1a, 0) == strlcpy(dest1b, src1b, 0) ? "Pass" : "Fail", 39 | strcmp(dest1a, dest1b) == 0 && strcmp(src1a, src1b) == 0 ? "Pass" : "Fail", 40 | ft_strlcpy(dest2a, src2a, 3) == strlcpy(dest2b, src2b, 3) ? "Pass" : "Fail", 41 | strcmp(dest2a, dest2b) == 0 && strcmp(src2a, src2b) == 0 ? "Pass" : "Fail", 42 | ft_strlcpy(dest3a, src3a, 0) == strlcpy(dest3b, src3b, 0) ? "Pass" : "Fail", 43 | strcmp(dest3a, dest3b) == 0 && strcmp(src3a, src3b) == 0 ? "Pass" : "Fail", 44 | ft_strlcpy(dest4a, src4a, 2) == strlcpy(dest4b, src4b, 2) ? "Pass" : "Fail", 45 | strcmp(dest4a, dest4b) == 0 && strcmp(src4a, src4b) == 0 ? "Pass" : "Fail"); 46 | } 47 | -------------------------------------------------------------------------------- /C03/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/12 09:18:40 by badam #+# #+# */ 9 | /* Updated: 2019/06/13 02:23:59 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | unsigned int ft_strlcat(char *dest, char *src, unsigned int size); 17 | 18 | int main(void) 19 | { 20 | char s1a[10] = "Test1"; 21 | char s2a[] = "OK"; 22 | char s1b[10] = "Test1"; 23 | char s2b[] = "OK"; 24 | char s3a[10] = "Same"; 25 | char s4a[] = "Size"; 26 | char s3b[10] = "Same"; 27 | char s4b[] = "Size"; 28 | char s5a[20] = "Shorter"; 29 | char s6a[] = "ThanMyself"; 30 | char s5b[20] = "Shorter"; 31 | char s6b[] = "ThanMyself"; 32 | char s7a[20] = "Shorter"; 33 | char s8a[] = "ThanMyself"; 34 | char s7b[20] = "Shorter"; 35 | char s8b[] = "ThanMyself"; 36 | 37 | printf("%s\n", ft_strlcat(s1a, s2a, 6) == strlcat(s1b, s2b, 6) ? "Success" : "Fail"); 38 | printf("%s\n", strcmp(s1a, s1b) == 0 && strcmp(s2a, s2b) == 0 ? "Success" : "Fail"); 39 | printf("%s\n", ft_strlcat(s3a, s4a, 10) == strlcat(s3b, s4b, 10) ? "Success" : "Fail"); 40 | printf("%s\n", strcmp(s3a, s3b) == 0 && strcmp(s4a, s4b) == 0 ? "Success" : "Fail"); 41 | printf("%s\n", ft_strlcat(s5a, s6a, 4) == strlcat(s5b, s6b, 4) ? "Success" : "Fail"); 42 | printf("%s\n", strcmp(s5a, s5b) == 0 && strcmp(s6a, s6b) == 0 ? "Success" : "Fail"); 43 | printf("%s\n", ft_strlcat(s7a, s8a, 0) == strlcat(s7b, s8b, 0) ? "Success" : "Fail"); 44 | printf("%s\n", strcmp(s7a, s7b) == 0 && strcmp(s8a, s8b) == 0 ? "Success" : "Fail"); 45 | 46 | /* 47 | printf("\n\nDetails:\n"); 48 | 49 | printf("%s:%s\n%s:%s\n", s1a, s1b, s2a, s2b); 50 | printf("%s:%s\n%s:%s\n", s3a, s3b, s4a, s4b); 51 | printf("%s:%s\n%s:%s\n", s5a, s5b, s6a, s6b); 52 | printf("%s:%s\n%s:%s\n", s7a, s7b, s8a, s8b); 53 | */ 54 | } 55 | -------------------------------------------------------------------------------- /C07/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 04:19:18 by badam #+# #+# */ 9 | /* Updated: 2019/06/27 04:29:17 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char **ft_split(char *str, char *charset); 17 | 18 | int c_strlen(char *str) 19 | { 20 | int len; 21 | 22 | len = 0; 23 | while (str[len]) 24 | len++; 25 | return (len); 26 | } 27 | 28 | int c_strctn(char *str1, char *str2, int at) 29 | { 30 | int len; 31 | int i; 32 | 33 | len = c_strlen(str2); 34 | i = 0; 35 | while (i < len) 36 | { 37 | str1[at + i] = str2[i]; 38 | i++; 39 | } 40 | str1[at + i] = 0; 41 | return (len + at); 42 | } 43 | 44 | char *c_strautojoin(char **strs, char *sep) 45 | { 46 | char *str; 47 | int len; 48 | int seplen; 49 | int i; 50 | int j; 51 | 52 | len = 1; 53 | seplen = c_strlen(sep); 54 | i = 0; 55 | while (strs[i] != NULL) 56 | { 57 | len += c_strlen(strs[i]); 58 | if (strs[i + 1] != NULL) 59 | len += seplen; 60 | i++; 61 | } 62 | str = malloc(len * sizeof(char)); 63 | i = 0; 64 | j = 0; 65 | while (strs[j]) 66 | { 67 | i = c_strctn(str, strs[j++], i); 68 | if (strs[j]) 69 | i = c_strctn(str, sep, i); 70 | } 71 | return (str); 72 | } 73 | 74 | int main(void) 75 | { 76 | char **tab; 77 | 78 | tab = ft_split("Ceci&est$un##############################################################################################################################################################succes@!", "&$#@"); 79 | printf("%s\n", c_strautojoin(tab, " ")); 80 | tab = ft_split("Success", "CUT"); 81 | printf("%s\n", c_strautojoin(tab, " ")); 82 | tab = ft_split("Success", ""); 83 | printf("%s\n", c_strautojoin(tab, " ")); 84 | tab = ft_split("", ""); 85 | printf("OK\n"); 86 | tab = ft_split("", "CUT"); 87 | printf("OK\n"); 88 | tab = ft_split(" ", " "); 89 | printf("OK\n"); 90 | tab = ft_split(" ", " "); 91 | printf("OK\n"); 92 | } 93 | -------------------------------------------------------------------------------- /C09/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/20 04:19:18 by badam #+# #+# */ 9 | /* Updated: 2019/06/27 04:29:17 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char **ft_split(char *str, char *charset); 17 | 18 | int c_strlen(char *str) 19 | { 20 | int len; 21 | 22 | len = 0; 23 | while (str[len]) 24 | len++; 25 | return (len); 26 | } 27 | 28 | int c_strctn(char *str1, char *str2, int at) 29 | { 30 | int len; 31 | int i; 32 | 33 | len = c_strlen(str2); 34 | i = 0; 35 | while (i < len) 36 | { 37 | str1[at + i] = str2[i]; 38 | i++; 39 | } 40 | str1[at + i] = 0; 41 | return (len + at); 42 | } 43 | 44 | char *c_strautojoin(char **strs, char *sep) 45 | { 46 | char *str; 47 | int len; 48 | int seplen; 49 | int i; 50 | int j; 51 | 52 | len = 1; 53 | seplen = c_strlen(sep); 54 | i = 0; 55 | while (strs[i] != NULL) 56 | { 57 | len += c_strlen(strs[i]); 58 | if (strs[i + 1] != NULL) 59 | len += seplen; 60 | i++; 61 | } 62 | str = malloc(len * sizeof(char)); 63 | i = 0; 64 | j = 0; 65 | while (strs[j]) 66 | { 67 | i = c_strctn(str, strs[j++], i); 68 | if (strs[j]) 69 | i = c_strctn(str, sep, i); 70 | } 71 | return (str); 72 | } 73 | 74 | int main(void) 75 | { 76 | char **tab; 77 | 78 | tab = ft_split("Ceci&est$un##############################################################################################################################################################succes@!", "&$#@"); 79 | printf("%s\n", c_strautojoin(tab, " ")); 80 | tab = ft_split("Success", "CUT"); 81 | printf("%s\n", c_strautojoin(tab, " ")); 82 | tab = ft_split("Success", ""); 83 | printf("%s\n", c_strautojoin(tab, " ")); 84 | tab = ft_split("", ""); 85 | printf("OK\n"); 86 | tab = ft_split("", "CUT"); 87 | printf("OK\n"); 88 | tab = ft_split(" ", " "); 89 | printf("OK\n"); 90 | tab = ft_split(" ", " "); 91 | printf("OK\n"); 92 | } 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Semi-auto-correct 42 2 | A correction tool for peer correction at 42 school (France) 3 | 4 | ## Utilisation 5 | 6 | ```shell 7 | cd && cd goinfre 8 | git clone https://github.com/Buom01/semi-auto-correct eval_${YOUR_USERNAME} 9 | cd eval_${YOUR_USERNAME} 10 | cd ${PROJET} 11 | git clone ${PROJET_GIT} eval 12 | ../correct.sh 13 | ``` 14 | 15 | Merci de mettre une Star si ce projet vous a été utile. 16 | 17 | Note: Je ne prenderais probablement pas le temps de faciliter l'utilisation de cet outil durant la piscine. L'utilisation de ce programme n'est pas très compliqué. 18 | 19 | ## Règles d'utilisations 20 | - Vous devez pouvoir expliquez les testes que vous effectuez à la personne corrigé (`cat ${PROJET}/${EXO}/main.c` ou `cat ${PROJET}/${EXO}/run.sh`) 21 | - Vous devez vérifier vous le code à la main, notamment les fonctions interdites. Ce projet n'est qu'un outils aidant à la correction qui réalise quelques testes supplémentaires en fournissant des fichiers `main.c` aux exercices de fonctions ou des fichiers `run.sh` aux exercices de programmes. 22 | - L'objectif est de passer vos 15min à expliquer les erreurs du corrigé et à lui proposé des solutions simple plutôt qu'uniquement tester ses programmes pendant 30min. 23 | - Merci de me créditer lorsque vous utilisez mon outil. 24 | - Je vous recommande donc de savoir comment résoudre les problèmes des fonctions soumises, tout comme de vérifier par vous même qu'il y a bien une erreur au cas où mon programme l'affirmerait. 25 | - Son usage se fait à vos risques et périls. Je ne pourait être tenu responsable des potentiels dommages ou préjudices qu'à réalisé cet outil. 26 | 27 | ## Conseils 28 | - Vérifiez bien que le projet que vous souhaitez corriger est disponible sur cet outil. 29 | - Utilisez-le sur vos projets avant de l'utiliser pour corriger les autres. 30 | - Expliquer bien au corrigé que vous utilisez un outil de correction, et préférez affirmer à qui appartient l'outil plutôt que d'affirmer vaguement qu'il appartient à un piscineux lambda. 31 | 32 | ## Avertissement 33 | J'essaie de mettre à jour mes tests en accord avec la moulinette pour pouvoir avoir une explication directe des erreurs du corrigé et lui permettre ainsi une meilleur compréhension de ses erreurs. 34 | Comprenez que la moulinette est une boite noir qui n'est pas constante dans le temps. Je vous recommande ainsi de checker régulièrement la partie 'issues' afin d'être au courant des différents changement reportés sur la moulinette. 35 | En cas de problème avec cet outil, vous en assumerez pleinement les conséquences. Cet outil est disponible tel quel. 36 | Ce document est suceptible de changer fréquement. Vous êtes tenu de vous tenir informé dès lors que vous utilisez l'outil `semi-auto-correct`. 37 | --------------------------------------------------------------------------------