42_C_PISCINE/Rush/Rush02/ex00/ft_print_error.c

43 lines
1.3 KiB
C
Raw Normal View History

2023-05-17 12:45:25 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nlauvray <nlauvray@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/31 08:39:29 by nlauvray #+# #+# */
/* Updated: 2022/07/31 08:40:57 by nlauvray ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_input_errors(char *str, char *tab)
{
int i;
i = -1;
while (str[++i])
{
if (str[i] != tab[i])
return (0);
}
return (1);
}
int ft_print_errors(char *str)
{
char *tab;
tab = malloc(sizeof(*tab) * ft_strlen(str));
tab = ft_tabnbr(ft_atoi(str));
if (ft_input_errors(str, tab) == 0)
{
free(tab);
write (1, "Error\n", 6);
return (0);
}
free(tab);
return (1);
}