42_push_swap/main.c
2022-12-09 15:22:02 +01:00

39 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/09 17:10:47 by cchauvet #+# #+# */
/* Updated: 2022/12/09 15:00:05 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int main(int argc, char *argv[])
{
int i;
long int *tab_a;
tab_a = malloc(argc * sizeof(long int));
if (tab_a == NULL)
return (1);
i = 1;
while (i < argc)
{
if (!ft_isnum(argv[i]))
{
write(2, "Error\n", 6);
free(tab_a);
return (1);
}
tab_a[i - 1] = ft_atoi(argv[i]);
i++;
}
if (argc > 2)
ft_sort(tab_a, i - 1);
return (0);
}