init
This commit is contained in:
BIN
Correction/C_07ma/ex01/a.out
Executable file
BIN
Correction/C_07ma/ex01/a.out
Executable file
Binary file not shown.
55
Correction/C_07ma/ex01/ft_range.c
Normal file
55
Correction/C_07ma/ex01/ft_range.c
Normal file
@ -0,0 +1,55 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_range.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/21 18:54:20 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/07/28 19:25:51 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int *ft_range(int min, int max)
|
||||
{
|
||||
int i;
|
||||
int *tab;
|
||||
|
||||
tab = NULL;
|
||||
if (max <= min)
|
||||
return (tab);
|
||||
tab = malloc(sizeof(*tab) * (max - min));
|
||||
i = 0;
|
||||
while (min + i < max)
|
||||
{
|
||||
*(tab + i) = min + i;
|
||||
i++;
|
||||
}
|
||||
return (tab);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int min;
|
||||
int max;
|
||||
int *tab;
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
i = 0;
|
||||
min = atoi(argv[1]);
|
||||
max = atoi(argv[2]);
|
||||
tab = ft_range(min, max);
|
||||
while (i < max - min)
|
||||
{
|
||||
printf("%d, ", *(tab + i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user