norminette

This commit is contained in:
2026-03-28 20:55:39 +01:00
parent 004b073669
commit bf668cf5e6
8 changed files with 342 additions and 358 deletions
+24 -22
View File
@@ -6,34 +6,36 @@
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/03/28 13:01:37 by dgaillet #+# #+# */
/* Updated: 2026/03/28 16:05:37 by lud-adam ### ########.fr */
/* Updated: 2026/03/28 20:52:29 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "../libft/libft.h"
#include "get_next_line.h"
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include "../inc/get_next_line.h"
#include "../libft/libft.h"
int check_input(int fd)
{
int i;
int j;
char *line;
int check_input(int fd) {
int i;
int j;
char *line = NULL;
line = get_next_line(fd);
j = 0;
while (line != NULL) {
i = -1;
while (line[++i])
if (!(line[i] >= '0' && line[i] <= '9') && line[i] != '\n')
return (free(line), -1);
if (ft_atoi(line) < 1 || ft_atoi(line) > 10000)
return (free(line), -1);
free(line);
j++;
line = get_next_line(fd);
}
return (j);
line = NULL;
line = get_next_line(fd);
j = 0;
while (line != NULL)
{
i = -1;
while (line[++i])
if (!(line[i] >= '0' && line[i] <= '9') && line[i] != '\n')
return (free(line), -1);
if (ft_atoi(line) < 1 || ft_atoi(line) > 10000)
return (free(line), -1);
free(line);
j++;
line = get_next_line(fd);
}
return (j);
}