This commit is contained in:
Loic Deridder
2025-02-11 16:01:16 +01:00
parent 5de086624e
commit 23791a53d9
14 changed files with 284 additions and 245 deletions

View File

@@ -87,7 +87,7 @@ int ft_printf(const char *fstr, ...);
int ft_fprintf(int fd, const char *str, ...);
char *ft_sprintf(const char *str, ...);
int ft_debug(const char *fstr, ...);
char *rep_c(char c, int count);
char *rep_c(char c, int count);
char *get_next_line(int fd, int del);

View File

@@ -23,7 +23,7 @@ static int ft_isspace(char c)
int is_only_space(char *str)
{
int i;
int i;
i = -1;
while (str[++i])

View File

@@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atol.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/11 15:40:16 by lderidde #+# #+# */
/* Updated: 2025/02/11 15:40:16 by lderidde ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../libft.h"
static int is_signed(char c, int *sign)
@@ -25,24 +37,16 @@ long ft_atol(const char *str)
str++;
while (*str >= '0' && *str <= '9')
{
if (((sign > 0) && res >= (LONG_MAX / 10) &&
(*str - '0' > LONG_MAX % 10))
|| (sign == -1 && res >= LONG_MAX / 10 && *str - '0' > LONG_MAX % 10 + 1))
if (((sign > 0) && res >= (LONG_MAX / 10)
&& (*str - '0' > LONG_MAX % 10))
|| (sign == -1 && res >= LONG_MAX / 10
&& *str - '0' > LONG_MAX % 10 + 1))
{
errno = ERANGE;
break;
break ;
}
res = (res * 10) + (*str - '0');
str++;
}
return (res * sign);
}
//
// #include <stdio.h>
//
// int main(int ac, char **av)
// {
// printf("res: %ld\n", ft_atol(av[1]));
// printf("errno: %d\n", errno);
//
// }

View File

@@ -12,9 +12,9 @@
#include "../../libft.h"
char *rep_c(char c, int count)
char *rep_c(char c, int count)
{
char *out;
char *out;
out = malloc(sizeof(char) * (count + 1));
ft_memset(out, c, count);