init
This commit is contained in:
BIN
Correction/correctionc07/ex02/a.out
Executable file
BIN
Correction/correctionc07/ex02/a.out
Executable file
Binary file not shown.
50
Correction/correctionc07/ex02/ft_ultimate_range.c
Normal file
50
Correction/correctionc07/ex02/ft_ultimate_range.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_ultimate_range.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/07/22 10:33:24 by cchauvet #+# #+# */
|
||||
/* Updated: 2022/08/01 17:27:36 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int ft_ultimate_range(int **range, int min, int max)
|
||||
{
|
||||
int i;
|
||||
|
||||
*range = NULL;
|
||||
if (max <= min)
|
||||
return (0);
|
||||
*range = malloc(sizeof(*range) * (max - min + 1));
|
||||
i = 0;
|
||||
while (min + i < max)
|
||||
{
|
||||
(*range)[i] = min + i;
|
||||
i++;
|
||||
}
|
||||
return (max - min);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
int temp1;
|
||||
int *temp2;
|
||||
int **tab;
|
||||
|
||||
temp1 = 0;
|
||||
temp2 =&temp1;
|
||||
tab = &temp2;
|
||||
printf("%d", ft_ultimate_range(tab, 11, 10));
|
||||
printf("\n");
|
||||
for (int ind = 0; ind<10; ind++ )
|
||||
{
|
||||
printf("%i, ", (*tab)[ind]);
|
||||
|
||||
}
|
||||
return (0);
|
||||
}
|
Reference in New Issue
Block a user