diff --git a/c_piscine_c_06/ex00/ft_print_program_name.c b/c_piscine_c_06/ex00/ft_print_program_name.c new file mode 100644 index 0000000..007051f --- /dev/null +++ b/c_piscine_c_06/ex00/ft_print_program_name.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_program_name.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apuchill +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/09 14:10:42 by apuchill #+# #+# */ +/* Updated: 2019/12/09 18:28:13 by apuchill ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int c; + + c = 0; + if (argc > 0) + { + while (argv[0][c] != '\0') + { + write(1, &argv[0][c], 1); + c++; + } + write(1, "\n", 1); + } + return (0); +} diff --git a/c_piscine_c_06/ex00/t_a.out b/c_piscine_c_06/ex00/t_a.out new file mode 100755 index 0000000..5c0b4c6 Binary files /dev/null and b/c_piscine_c_06/ex00/t_a.out differ diff --git a/c_piscine_c_06/ex01/ft_print_params.c b/c_piscine_c_06/ex01/ft_print_params.c new file mode 100644 index 0000000..d9e6a90 --- /dev/null +++ b/c_piscine_c_06/ex01/ft_print_params.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apuchill +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/09 14:20:32 by apuchill #+# #+# */ +/* Updated: 2019/12/09 18:28:30 by apuchill ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int c; + int d; + + c = 1; + d = 0; + if (argc > 1) + { + while (c < argc) + { + d = 0; + while (argv[c][d] != '\0') + { + write(1, &argv[c][d], 1); + d++; + } + write(1, "\n", 1); + c++; + } + } + return (0); +} diff --git a/c_piscine_c_06/ex01/t_a.out b/c_piscine_c_06/ex01/t_a.out new file mode 100755 index 0000000..da588a5 Binary files /dev/null and b/c_piscine_c_06/ex01/t_a.out differ diff --git a/c_piscine_c_06/ex02/ft_rev_params.c b/c_piscine_c_06/ex02/ft_rev_params.c new file mode 100644 index 0000000..22ec11a --- /dev/null +++ b/c_piscine_c_06/ex02/ft_rev_params.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_rev_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apuchill +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/09 14:20:32 by apuchill #+# #+# */ +/* Updated: 2019/12/09 18:28:41 by apuchill ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +int main(int argc, char **argv) +{ + int c; + int d; + + c = argc - 1; + d = 0; + if (argc > 1) + { + while (c > 0) + { + d = 0; + while (argv[c][d] != '\0') + { + write(1, &argv[c][d], 1); + d++; + } + write(1, "\n", 1); + c--; + } + } + return (0); +} diff --git a/c_piscine_c_06/ex02/t_a.out b/c_piscine_c_06/ex02/t_a.out new file mode 100755 index 0000000..252f30b Binary files /dev/null and b/c_piscine_c_06/ex02/t_a.out differ diff --git a/c_piscine_c_06/ex03/ft_sort_params.c b/c_piscine_c_06/ex03/ft_sort_params.c new file mode 100644 index 0000000..0524121 --- /dev/null +++ b/c_piscine_c_06/ex03/ft_sort_params.c @@ -0,0 +1,73 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sort_params.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: apuchill +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/12/09 16:33:03 by apuchill #+# #+# */ +/* Updated: 2019/12/09 18:28:55 by apuchill ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include + +void ft_putstr(const char *str) +{ + int c; + + c = 0; + while (str[c] != '\0') + { + write(1, &str[c], 1); + c++; + } + write(1, "\n", 1); +} + +int ft_strcmp(const char *s1, const char *s2) +{ + int c; + + c = 0; + while ((s1[c] == s2[c]) && (s1[c] != '\0') && (s2[c] != '\0')) + c++; + return (s1[c] - s2[c]); +} + +void ft_swap(int *a, int *b) +{ + int aux; + + aux = *a; + *a = *b; + *b = aux; +} + +int main(int argc, const char **argv) +{ + int qty; + int c; + int d; + int arg[argc]; + + qty = 1; + c = 1; + while (qty < argc) + { + arg[qty] = qty; + qty++; + } + while (c < argc) + { + d = c; + while (d < argc) + { + if (ft_strcmp(argv[arg[c]], argv[arg[d]]) > 0) + ft_swap(&arg[c], &arg[d]); + d++; + } + ft_putstr(argv[arg[c++]]); + } + return (0); +} diff --git a/c_piscine_c_06/ex03/t_a.out b/c_piscine_c_06/ex03/t_a.out new file mode 100755 index 0000000..7b5eeaa Binary files /dev/null and b/c_piscine_c_06/ex03/t_a.out differ