diff options
Diffstat (limited to '')
| -rw-r--r-- | libft/Makefile | 3 | ||||
| -rw-r--r-- | libft/include/libft.h | 3 | ||||
| -rw-r--r-- | libft/src/ft_strclen.c | 24 | ||||
| -rw-r--r-- | libft/src/ft_strlen.c | 2 | 
4 files changed, 29 insertions, 3 deletions
| diff --git a/libft/Makefile b/libft/Makefile index ac06d94..7b1c22c 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -24,6 +24,8 @@ SRCS_NAME	+= ft_memchr.c  SRCS_NAME	+= ft_memlchr.c  SRCS_NAME	+= ft_memcmp.c  SRCS_NAME	+= ft_strlen.c +SRCS_NAME	+= ft_strclen.c +SRCS_NAME	+= ft_strnlen.c  SRCS_NAME	+= ft_isalpha.c  SRCS_NAME	+= ft_isdigit.c  SRCS_NAME	+= ft_isalnum.c @@ -71,7 +73,6 @@ SRCS_NAME	+= ft_putstr.c  SRCS_NAME	+= ft_putendl.c  SRCS_NAME	+= ft_putnbr.c  SRCS_NAME	+= ft_putnbr_base.c -SRCS_NAME	+= ft_strnlen.c  SRCS_NAME	+= ft_strcat.c  SRCS_NAME	+= ft_strcmp.c  SRCS_NAME	+= ft_isspace.c diff --git a/libft/include/libft.h b/libft/include/libft.h index 6513693..0cd5ed1 100644 --- a/libft/include/libft.h +++ b/libft/include/libft.h @@ -148,9 +148,10 @@ int						ft_strcmp(const char *s1, const char *s2);  long					ft_memlchr(const void *s, int c, size_t n);  long					ft_strlchr(const char *s, int c);  size_t					ft_strlen(const char *s); +size_t					ft_strclen(const char *s, int c); +size_t					ft_strnlen(const char *s, size_t size);  size_t					ft_strlcpy(char *dst, const char *src, size_t size);  size_t					ft_strlcat(char *dst, const char *src, size_t size); -size_t					ft_strnlen(const char *s, size_t size);  double					ft_sqrt(double x);  /* diff --git a/libft/src/ft_strclen.c b/libft/src/ft_strclen.c new file mode 100644 index 0000000..fe88ca5 --- /dev/null +++ b/libft/src/ft_strclen.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   ft_strclen.c                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:07:12 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:07:12 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#include <stddef.h> + +size_t +	ft_strclen(const char *s, int c) +{ +	const char *ptr; + +	ptr = s; +	while (ptr != NULL && *ptr != '\0' && *ptr != c) +		ptr++; +	return (ptr - s); +} diff --git a/libft/src/ft_strlen.c b/libft/src/ft_strlen.c index 90f5110..2b26bf0 100644 --- a/libft/src/ft_strlen.c +++ b/libft/src/ft_strlen.c @@ -18,7 +18,7 @@ size_t  	const char *ptr;  	ptr = s; -	while (ptr && *ptr) +	while (ptr != NULL && *ptr != '\0')  		ptr++;  	return (ptr - s);  } | 
