diff options
Diffstat (limited to 'lib/libft')
| -rw-r--r-- | lib/libft/Makefile | 2 | ||||
| -rw-r--r-- | lib/libft/ft_isspace.c | 20 | ||||
| -rw-r--r-- | lib/libft/ft_memset.c | 14 | ||||
| -rw-r--r-- | lib/libft/ft_strncpy.c | 21 | ||||
| -rw-r--r-- | lib/libft/libft.h | 6 |
5 files changed, 59 insertions, 4 deletions
diff --git a/lib/libft/Makefile b/lib/libft/Makefile index 3c2fb91..6f2950c 100644 --- a/lib/libft/Makefile +++ b/lib/libft/Makefile @@ -10,6 +10,7 @@ SRC = ft_atoi.c \ ft_isascii.c \ ft_isdigit.c \ ft_isprint.c \ + ft_isspace.c \ ft_itoa.c \ ft_memchr.c \ ft_memcmp.c \ @@ -30,6 +31,7 @@ SRC = ft_atoi.c \ ft_strlen.c \ ft_strmapi.c \ ft_strncmp.c \ + ft_strncpy.c \ ft_strnstr.c \ ft_strrchr.c \ ft_strtrim.c \ diff --git a/lib/libft/ft_isspace.c b/lib/libft/ft_isspace.c new file mode 100644 index 0000000..63f21fa --- /dev/null +++ b/lib/libft/ft_isspace.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isspace.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/11 13:59:45 by chuhlig #+# #+# */ +/* Updated: 2024/08/11 14:04:23 by chuhlig ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_isspace(char c) +{ + if (c == ' ' || c == '\t') + return (1); + return (0); +} diff --git a/lib/libft/ft_memset.c b/lib/libft/ft_memset.c index 58c5e1e..085df1d 100644 --- a/lib/libft/ft_memset.c +++ b/lib/libft/ft_memset.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_memset.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 09:58:19 by dkaiser #+# #+# */ -/* Updated: 2024/03/10 13:13:09 by dkaiser ### ########.fr */ +/* Updated: 2024/07/11 23:52:13 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,3 +35,13 @@ void *ft_memset(void *b, int c, size_t len) /* printf("ft_memset: %s\n", ft_memset((char *)str, 'A' + 255, 5)); */ /* printf("memset: %s\n", memset((char *)str, 'A' + 255, 5)); */ /* } */ + +// void *ft_memset(void *b, int c, size_t len) +// { +// void *savearg; + +// savearg = b; +// while (len--) +// *(unsigned char *)b++ = (unsigned char)c; +// return (savearg); +// }
\ No newline at end of file diff --git a/lib/libft/ft_strncpy.c b/lib/libft/ft_strncpy.c new file mode 100644 index 0000000..a1a2293 --- /dev/null +++ b/lib/libft/ft_strncpy.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/08/05 13:41:47 by chuhlig #+# #+# */ +/* Updated: 2024/08/09 15:26:40 by chuhlig ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strncpy(char *s1, char *s2, int n) +{ + int i; + + i = -1; + while (++i < n && s2[i]) + s1[i] = s2[i]; + return (s1); +} diff --git a/lib/libft/libft.h b/lib/libft/libft.h index 2de723b..abb739d 100644 --- a/lib/libft/libft.h +++ b/lib/libft/libft.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* libft.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/10 16:37:54 by dkaiser #+# #+# */ -/* Updated: 2024/06/24 16:44:44 by dkaiser ### ########.fr */ +/* Updated: 2024/08/11 14:01:57 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,6 +24,7 @@ int ft_isalpha(int c); int ft_isdigit(int c); int ft_isalnum(int c); int ft_isprint(int c); +int ft_isspace(char c); int ft_isascii(int c); int ft_strlen(const char *str); void *ft_memset(void *b, int c, size_t len); @@ -57,6 +58,7 @@ void ft_putchar_fd(char c, int fd); void ft_putstr_fd(char *s, int fd); void ft_putendl_fd(char *s, int fd); void ft_putnbr_fd(int n, int fd); +char *ft_strncpy(char *s1, char *s2, int n); typedef struct s_list { |
