mirror of
https://github.com/LucasCodeur/alcu.git
synced 2026-04-28 17:44:34 +02:00
norminette
This commit is contained in:
+24
-22
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user