c fini bro

This commit is contained in:
Camille Chauvet 2022-12-11 17:56:20 +01:00
parent ea2251bed4
commit 32be727085
22 changed files with 51 additions and 37 deletions

View File

@ -6,15 +6,15 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/08 18:27:58 by cchauvet #+# #+# */
/* Updated: 2022/12/02 21:39:08 by cchauvet ### ########.fr */
/* Updated: 2022/12/11 17:41:54 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int ft_atoi(char *str)
long int ft_atoi(char *str)
{
int nb;
long int nb;
int i;
int sign;

BIN
ft_atoi.o

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/08 18:43:06 by cchauvet #+# #+# */
/* Updated: 2022/11/08 19:52:48 by cchauvet ### ########.fr */
/* Updated: 2022/12/11 17:49:49 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,10 +14,24 @@
int ft_isnum(char *str)
{
long int i;
int sign;
sign = 1;
if (*str == '-')
sign = -1;
i = 0;
if (*str == '-' || *str == '+')
str++;
if (*str == '\0')
return (0);
while (*str != '\0')
{
if (!((*str >= '0' && *str <= '9') || *str == '-' || *str == '+'))
if (i * sign > INT_MAX || INT_MIN > i * sign)
return (0);
if (!(*str >= '0' && *str <= '9'))
return (0);
i = i * 10 + *str - '0';
str++;
}
return (1);

Binary file not shown.

BIN
ft_p.o

Binary file not shown.

Binary file not shown.

BIN
ft_r.o

Binary file not shown.

Binary file not shown.

BIN
ft_rr.o

Binary file not shown.

BIN
ft_s.o

Binary file not shown.

BIN
ft_sort.o

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
ft_swap.o

Binary file not shown.

Binary file not shown.

17
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/09 17:10:47 by cchauvet #+# #+# */
/* Updated: 2022/12/11 15:48:20 by cchauvet ### ########.fr */
/* Updated: 2022/12/11 17:52:08 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -37,7 +37,7 @@ void ft_error(char **splitted)
ft_cancel(splitted, len);
}
int ft_parse(long int *tab, const char *s)
int ft_parse(long int *tab, const char *s, int index)
{
char **splitted;
int i;
@ -45,21 +45,22 @@ int ft_parse(long int *tab, const char *s)
splitted = ft_split(s, ' ');
if (splitted == NULL)
return (1);
i = 0;
while (splitted[i] != NULL)
i = -1;
if (splitted[0] == NULL)
write(2, "Error\n", 6);
while (splitted[++i] != NULL)
{
if (!ft_isnum(splitted[i]))
{
ft_error(splitted);
return (0);
}
tab[i] = ft_atoi(splitted[i]);
if (ft_isin(tab, i, tab[i]))
tab[index + i] = ft_atoi(splitted[i]);
if (ft_isin(tab, index + i, tab[index + i]))
{
ft_error(splitted);
return (0);
}
i++;
}
ft_cancel(splitted, i + 1);
return (i);
@ -94,7 +95,7 @@ int main(int argc, char *argv[])
len = 0;
while (++i < argc)
{
y = ft_parse(tab_a + len, argv[i]);
y = ft_parse(tab_a, argv[i], (int) len);
if (y == 0)
{
free(tab_a);

BIN
main.o

Binary file not shown.

BIN
push_swap

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/08 18:19:44 by cchauvet #+# #+# */
/* Updated: 2022/12/11 15:08:16 by cchauvet ### ########.fr */
/* Updated: 2022/12/11 17:55:38 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,12 +15,11 @@
# include <unistd.h>
# include <stdlib.h>
# include <limits.h>
//# include <stdio.h>
# define STOP_VALUE 4294967295
int ft_isnum(char *str);
size_t ft_strlen(const char *s);
int ft_atoi(char *str);
long int ft_atoi(char *str);
void ft_putstr(char *str);
size_t ft_seglen(const char *s, char c);
char **ft_split(const char *s, char c);
@ -46,5 +45,5 @@ void ft_rra(unsigned int *tab_a);
void ft_rrb(unsigned int *tab_b);
void ft_sa(unsigned int *tab_a);
typedef unsigned int * t_tab;
typedef unsigned int *t_tab;
#endif