Exos
This commit is contained in:
25
ex0/ft_print_program_name.c
Normal file
25
ex0/ft_print_program_name.c
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_print_program_name.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/19 15:36:50 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/19 18:05:56 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
|
i = 0;
|
||||||
|
while (argv[0][i] != '\0')
|
||||||
|
i++;
|
||||||
|
write(1, argv[0], i);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
}
|
||||||
32
ex1/ft_print_params.c
Normal file
32
ex1/ft_print_params.c
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_print_params.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/19 16:03:11 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/19 18:05:40 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
|
i = 1;
|
||||||
|
while (i < argc)
|
||||||
|
{
|
||||||
|
len = 0;
|
||||||
|
while (argv[i][len] != '\0')
|
||||||
|
len++;
|
||||||
|
write(1, argv[i], len);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
32
ex2/ft_rev_params.c
Normal file
32
ex2/ft_rev_params.c
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_rev_params.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/19 16:09:13 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/19 18:05:23 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
|
i = argc - 1;
|
||||||
|
while (i > 0)
|
||||||
|
{
|
||||||
|
len = 0;
|
||||||
|
while (argv[i][len] != '\0')
|
||||||
|
len++;
|
||||||
|
write(1, argv[i], len);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
68
ex3/ft_sort_params.c
Normal file
68
ex3/ft_sort_params.c
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_sort_params.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lclerel- <lclerel-@learner.42.tech> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2026/03/19 16:47:37 by lclerel- #+# #+# */
|
||||||
|
/* Updated: 2026/03/19 18:09:21 by lclerel- ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int ft_strcmp(char *s1, char *s2)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (s1[i] != '\0' && s1[i] == s2[i])
|
||||||
|
i++;
|
||||||
|
return (s1[i] - s2[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ft_display(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
while (i < argc)
|
||||||
|
{
|
||||||
|
len = 0;
|
||||||
|
while (argv[i][len])
|
||||||
|
len++;
|
||||||
|
write(1, argv[i], len);
|
||||||
|
write(1, "\n", 1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
char *temp;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
return (0);
|
||||||
|
i = 1;
|
||||||
|
while (i < argc - 1)
|
||||||
|
{
|
||||||
|
j = i + 1;
|
||||||
|
while (j < argc)
|
||||||
|
{
|
||||||
|
if (ft_strcmp(argv[i], argv[j]) > 0)
|
||||||
|
{
|
||||||
|
temp = argv[i];
|
||||||
|
argv[i] = argv[j];
|
||||||
|
argv[j] = temp;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ft_display(argc, argv);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user