diff options
| author | Christopher Uhlig | 2025-01-13 11:06:54 +0100 |
|---|---|---|
| committer | Christopher Uhlig | 2025-01-13 11:06:54 +0100 |
| commit | 78dc50a2bce3c6e31405437189e2990d8fc720ac (patch) | |
| tree | d61d9f0d279e191c1bfb34929908f412cf58c02d /lib | |
| parent | ae5512ea0d6d8be833ca3a9b39f93239109f45b4 (diff) | |
| download | minishell-78dc50a2bce3c6e31405437189e2990d8fc720ac.tar.gz minishell-78dc50a2bce3c6e31405437189e2990d8fc720ac.zip | |
here
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libft/Makefile | 3 | ||||
| -rw-r--r-- | lib/libft/ft_strcat.c | 29 | ||||
| -rw-r--r-- | lib/libft/ft_strcmp.c | 23 | ||||
| -rw-r--r-- | lib/libft/ft_strcpy.c | 25 | ||||
| -rw-r--r-- | lib/libft/libft.h | 5 |
5 files changed, 84 insertions, 1 deletions
diff --git a/lib/libft/Makefile b/lib/libft/Makefile index 6f2950c..2150e99 100644 --- a/lib/libft/Makefile +++ b/lib/libft/Makefile @@ -26,6 +26,8 @@ SRC = ft_atoi.c \ ft_strdup.c \ ft_striteri.c \ ft_strjoin.c \ + ft_strcat.c \ + ft_strcpy.c \ ft_strlcat.c \ ft_strlcpy.c \ ft_strlen.c \ @@ -45,6 +47,7 @@ SRC = ft_atoi.c \ get_next_line.c \ get_next_line_utils.c \ ft_atol.c \ + ft_strcmp.c \ ft_lstnew_bonus.c \ ft_lstadd_front_bonus.c \ ft_lstsize_bonus.c \ diff --git a/lib/libft/ft_strcat.c b/lib/libft/ft_strcat.c new file mode 100644 index 0000000..648c184 --- /dev/null +++ b/lib/libft/ft_strcat.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/01/09 13:06:44 by chuhlig #+# #+# */ +/* Updated: 2025/01/09 13:07:15 by chuhlig ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcat(char *dest, char *src) +{ + int i; + int j; + + j = 0; + i = 0; + while (dest[i]) + i++; + while (src[j]) + { + dest[i + j] = src[j]; + j++; + } + dest[i + j] = '\0'; + return (dest); +}
\ No newline at end of file diff --git a/lib/libft/ft_strcmp.c b/lib/libft/ft_strcmp.c new file mode 100644 index 0000000..af7b2a1 --- /dev/null +++ b/lib/libft/ft_strcmp.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/12/18 19:03:14 by chuhlig #+# #+# */ +/* Updated: 2024/12/18 19:05:01 by chuhlig ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] && s1[i] == s2[i]) + i++; + return (s1[i] - s2[i]); +}
\ No newline at end of file diff --git a/lib/libft/ft_strcpy.c b/lib/libft/ft_strcpy.c new file mode 100644 index 0000000..b5c612f --- /dev/null +++ b/lib/libft/ft_strcpy.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/01/09 14:38:30 by chuhlig #+# #+# */ +/* Updated: 2025/01/09 14:38:53 by chuhlig ### ########.fr */ +/* */ +/* ************************************************************************** */ + +char *ft_strcpy(char *dest, char *src) +{ + int i; + + i = 0; + while (src[i] != '\0') + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return (dest); +}
\ No newline at end of file diff --git a/lib/libft/libft.h b/lib/libft/libft.h index abb739d..6b4c824 100644 --- a/lib/libft/libft.h +++ b/lib/libft/libft.h @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/10 16:37:54 by dkaiser #+# #+# */ -/* Updated: 2024/08/11 14:01:57 by chuhlig ### ########.fr */ +/* Updated: 2025/01/09 14:39:28 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,7 @@ int ft_isalnum(int c); int ft_isprint(int c); int ft_isspace(char c); int ft_isascii(int c); +int ft_strcmp(char *s1, char *s2); int ft_strlen(const char *str); void *ft_memset(void *b, int c, size_t len); void ft_bzero(void *s, size_t n); @@ -59,6 +60,8 @@ 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); +char *ft_strcat(char *dest, char *src); +char *ft_strcpy(char *dest, char *src); typedef struct s_list { |
