m
This commit is contained in:
		
							
								
								
									
										64
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,64 @@ | ||||
| # **************************************************************************** # | ||||
| #                                                                              # | ||||
| #                                                         :::      ::::::::    # | ||||
| #    Makefile                                           :+:      :+:    :+:    # | ||||
| #                                                     +:+ +:+         +:+      # | ||||
| #    By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+         # | ||||
| #                                                 +#+#+#+#+#+   +#+            # | ||||
| #    Created: 2022/09/27 08:39:27 by cchauvet          #+#    #+#              # | ||||
| #    Updated: 2022/09/27 16:08:49 by cchauvet         ###   ########.fr        # | ||||
| #                                                                              # | ||||
| # **************************************************************************** # | ||||
|  | ||||
| SRCS = ft_isalpha.c \ | ||||
| 	   ft_isdigit.c \ | ||||
| 	   ft_isalnum.c \ | ||||
| 	   ft_isascii.c \ | ||||
| 	   ft_isprint.c \ | ||||
| 	   ft_strlen.c \ | ||||
| 	   ft_memset.c \ | ||||
| 	   ft_bzero.c \ | ||||
| 	   ft_toupper.c \ | ||||
| 	   ft_tolower.c \ | ||||
| 	   ft_strchr.c \ | ||||
| 	   ft_strrchr.c \ | ||||
| 	   ft_strncmp.c \ | ||||
| 	   ft_memcpy.c \ | ||||
| 	   ft_memmove.c \ | ||||
| 	   ft_memchr.c \ | ||||
| 	   ft_memcmp.c \ | ||||
| 	   ft_strdup.c \ | ||||
| 	   ft_calloc.c | ||||
|  | ||||
| COMMENT = ft_strlcpy.c \ | ||||
| 	   ft_strlcat.c \ | ||||
| 	   ft_strnstr.c \ | ||||
| 	   ft_atoi.c \ | ||||
| 	   ft_strdup.c | ||||
|  | ||||
| OBJS = ${SRCS:.c=.o} | ||||
|  | ||||
| NAME = libft | ||||
|  | ||||
| CFLAG = -Wall -Werror -Wextra | ||||
|  | ||||
| all: | ||||
| 	gcc -c ${CFLAG} ${SRCS} | ||||
| 	ar rc ${NAME}.a ${OBJS} | ||||
|  | ||||
| clean: | ||||
| 	rm -f ${OBJS} | ||||
|  | ||||
| fclean: | ||||
| 	rm -f ${OBJS} | ||||
| 	rm -f ${NAME}.a | ||||
|  | ||||
| re: | ||||
| 	rm -f ${OBJS} | ||||
| 	rm -f ${NAME}.a | ||||
| 	gcc -c ${CFLAG} ${SRCS} | ||||
| 	ar rc ${NAME}.a ${OBJS} | ||||
|  | ||||
| so: | ||||
| 	$(CC) -nostartfiles -fPIC $(CFLAGS) $(SRC) | ||||
| 	gcc -nostartfiles -shared -o libft.so $(OBJ) | ||||
							
								
								
									
										36
									
								
								ft_atoi.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								ft_atoi.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_atoi.c                                          :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 16:14:34 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 16:22:36 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_atoi(const char *nptr) | ||||
| { | ||||
| 	char	*str; | ||||
| 	int		out; | ||||
| 	int		sign; | ||||
|  | ||||
| 	out = 0; | ||||
| 	while (*str == " ") | ||||
| 		str++; | ||||
| 	sign = 1; | ||||
| 	if (*str == '-') | ||||
| 	{ | ||||
| 		sign = -1; | ||||
| 		str++; | ||||
| 	} | ||||
| 	while (ft_isdigit(*str)) | ||||
| 	{ | ||||
| 		out = 10 * out + *str - 48; | ||||
| 		*str++; | ||||
| 	} | ||||
| 	return (out * sign) | ||||
| } | ||||
							
								
								
									
										18
									
								
								ft_bzero.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								ft_bzero.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_bzero.c                                         :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 09:40:13 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 09:41:02 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| void	ft_bzero(void *s, size_t n) | ||||
| { | ||||
| 	ft_memset(s, 0, n); | ||||
| } | ||||
							
								
								
									
										24
									
								
								ft_calloc.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ft_calloc.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_calloc.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 16:09:01 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 16:12:30 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| void	*calloc(size_t nmemb, size_t size) | ||||
| { | ||||
| 	char	*tab; | ||||
|  | ||||
| 	if (nmemb * size == 0) | ||||
| 		return (NULL); | ||||
| 	tab = malloc(nmemb * size); | ||||
| 	ft_bzero(tab, nmemb * size); | ||||
| 	return (tab); | ||||
| } | ||||
							
								
								
									
										22
									
								
								ft_isalnum.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								ft_isalnum.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_isalnum.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 11:15:04 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:32:40 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_isalnum(int c) | ||||
| { | ||||
| 	if ((('9' >= c && c >= '0') | ||||
| 			|| ('z' >= c && c >= 'a') | ||||
| 			|| ('Z' >= c && c >= 'A'))) | ||||
| 		return (1); | ||||
| 	return (0); | ||||
| } | ||||
							
								
								
									
										20
									
								
								ft_isalpha.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ft_isalpha.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_isalpha.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 11:15:04 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:04:58 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_isalpha(int c) | ||||
| { | ||||
| 	if (('z' >= c && c >= 'a') || ('Z' >= c && c >= 'A')) | ||||
| 		return (1); | ||||
| 	return (0); | ||||
| } | ||||
							
								
								
									
										18
									
								
								ft_isascii.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								ft_isascii.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_isascii.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 11:57:55 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/26 13:33:50 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| int	ft_isascii(int c) | ||||
| { | ||||
| 	if (c >= 0 && 127 >= c) | ||||
| 		return (1); | ||||
| 	return (0); | ||||
| } | ||||
							
								
								
									
										20
									
								
								ft_isdigit.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ft_isdigit.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_isdigit.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 11:15:04 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:09:19 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_isdigit(int c) | ||||
| { | ||||
| 	if ('9' >= c && c >= '0') | ||||
| 		return (1); | ||||
| 	return (0); | ||||
| } | ||||
							
								
								
									
										18
									
								
								ft_isprint.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								ft_isprint.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_isprint.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 11:52:31 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 15:46:02 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_isprint(int c) | ||||
| { | ||||
| 	return (32 <= c && c <= 127); | ||||
| } | ||||
							
								
								
									
										31
									
								
								ft_memchr.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								ft_memchr.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_memchr.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 13:40:09 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 13:59:03 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| void	*ft_memchr(const void *s, int c, size_t n) | ||||
| { | ||||
| 	unsigned char	*tab; | ||||
| 	size_t			i; | ||||
| 	unsigned char	tofind; | ||||
|  | ||||
| 	tab = (unsigned char *) s; | ||||
| 	tofind = (unsigned char) c; | ||||
| 	i = 0; | ||||
| 	while (i < n) | ||||
| 	{ | ||||
| 		if (tab[i] == tofind) | ||||
| 			return (tab + i); | ||||
| 		i++; | ||||
| 	} | ||||
| 	return (NULL); | ||||
| } | ||||
							
								
								
									
										29
									
								
								ft_memcmp.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								ft_memcmp.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_memcmp.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 14:15:37 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 15:10:56 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_memcmp(const void *s1, const void *s2, size_t n) | ||||
| { | ||||
| 	unsigned char	*str1; | ||||
| 	unsigned char	*str2; | ||||
| 	size_t			i; | ||||
|  | ||||
| 	if (n == 0) | ||||
| 		return (0); | ||||
| 	str1 = (unsigned char *) s1; | ||||
| 	str2 = (unsigned char *) s2; | ||||
| 	i = 0; | ||||
| 	while (str1[i] == str2[i] && i < n - 1) | ||||
| 		i++; | ||||
| 	return (str1[i] - str2[i]); | ||||
| } | ||||
							
								
								
									
										32
									
								
								ft_memcpy.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								ft_memcpy.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_memcpy.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 09:42:11 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 15:07:20 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| void	*ft_memcpy(void *dest, const void *src, size_t n) | ||||
| { | ||||
| 	char	*tab1; | ||||
| 	char	*tab2; | ||||
| 	size_t	i; | ||||
|  | ||||
| 	if (dest == NULL || src == NULL) | ||||
| 		return (NULL); | ||||
| 	tab1 = dest; | ||||
| 	tab2 = (void *) src; | ||||
| 	i = 0; | ||||
| 	while (i < n) | ||||
| 	{ | ||||
| 			tab1[i] = tab2[i]; | ||||
| 			i++; | ||||
| 	} | ||||
| 	return (tab1); | ||||
| } | ||||
							
								
								
									
										35
									
								
								ft_memmove.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								ft_memmove.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_memmove.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 11:44:12 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 14:14:24 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| void	*ft_memmove(void *dest, const void *src, size_t n) | ||||
| { | ||||
| 	size_t	i; | ||||
| 	char	*tab1; | ||||
| 	char	*tab2; | ||||
|  | ||||
| 	tab1 = dest; | ||||
| 	tab2 = (void *) src; | ||||
| 	if (tab1 < tab2) | ||||
| 		ft_memcpy(dest, src, n); | ||||
| 	else | ||||
| 	{ | ||||
| 		i = n; | ||||
| 		while (0 < i) | ||||
| 		{ | ||||
| 			i--; | ||||
| 			tab1[i] = tab2[i]; | ||||
| 		} | ||||
| 	} | ||||
| 	return (dest); | ||||
| } | ||||
							
								
								
									
										28
									
								
								ft_memset.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								ft_memset.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_memset.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 09:29:51 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 09:48:23 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| void	*ft_memset(void *s, int c, size_t n) | ||||
| { | ||||
| 	char	*tab; | ||||
| 	size_t	i; | ||||
|  | ||||
| 	tab = s; | ||||
| 	i = 0; | ||||
| 	while (i < n) | ||||
| 	{ | ||||
| 		tab[i] = c; | ||||
| 		i++; | ||||
| 	} | ||||
| 	return (s); | ||||
| } | ||||
							
								
								
									
										24
									
								
								ft_strchr.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ft_strchr.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strchr.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 14:44:15 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:30:30 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| char	*strchr(const char *s, int c) | ||||
| { | ||||
| 	while (*s) | ||||
| 	{ | ||||
| 		if (*s == c) | ||||
| 			return ((char *) s); | ||||
| 		s++; | ||||
| 	} | ||||
| 	return (NULL); | ||||
| } | ||||
							
								
								
									
										31
									
								
								ft_strdup.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								ft_strdup.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strdup.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 16:00:49 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 16:07:00 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| char	*strdup(const char *s) | ||||
| { | ||||
| 	char	*in; | ||||
| 	char	*out; | ||||
| 	size_t	i; | ||||
|  | ||||
| 	in = (char *) s; | ||||
| 	out = malloc(sizeof(char) * (ft_strlen(in) + 1)); | ||||
| 	i = 0; | ||||
| 	while (in[i]) | ||||
| 	{ | ||||
| 		out[i] = in[i]; | ||||
| 		i++; | ||||
| 	} | ||||
| 	out[i] = 0; | ||||
| 	return (out); | ||||
| } | ||||
							
								
								
									
										29
									
								
								ft_strlcpy.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								ft_strlcpy.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strlcpy.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 16:24:15 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 16:29:08 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| char	*strlcpy(char *dst, const char *src, size_t size) | ||||
| { | ||||
| 	char	*str; | ||||
| 	size_t	i; | ||||
|  | ||||
| 	i = 0; | ||||
| 	str = (char *) src; | ||||
| 	while (str[i + 1] && dst[i + 1] && i < size - 1) | ||||
| 	{ | ||||
| 		dst[i] = src[i]; | ||||
| 		i++; | ||||
| 	} | ||||
| 	dst[i] = 0; | ||||
| 	return (dst); | ||||
| } | ||||
							
								
								
									
										22
									
								
								ft_strlen.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								ft_strlen.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strlen.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 12:03:59 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 09:02:11 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
| #include <stddef.h> | ||||
|  | ||||
| size_t	ft_strlen(const char *s) | ||||
| { | ||||
| 	size_t	length; | ||||
|  | ||||
| 	length = 0; | ||||
| 	while (s[length]) | ||||
| 		length++; | ||||
| 	return (length); | ||||
| } | ||||
							
								
								
									
										23
									
								
								ft_strncmp.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								ft_strncmp.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strncmp.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 08:30:26 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 08:36:25 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	strncmp(const char *s1, const char *s2, size_t n) | ||||
| { | ||||
| 	size_t	i; | ||||
|  | ||||
| 	i = 0; | ||||
| 	while (s1[i] == s2[i] && i < n - 1 && s1[i] && s2[i]) | ||||
| 		i++; | ||||
| 	return (s1[i] - s2[i]); | ||||
| } | ||||
							
								
								
									
										27
									
								
								ft_strrchr.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								ft_strrchr.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strrchr.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/27 08:25:33 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:29:58 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| char	*strrchr(const char *s, int c) | ||||
| { | ||||
| 	char	*ret; | ||||
|  | ||||
| 	ret = NULL; | ||||
| 	while (*s) | ||||
| 	{ | ||||
| 		if (*s == (char) c) | ||||
| 			ret = (char *) s; | ||||
| 		s++; | ||||
| 	} | ||||
| 	return (ret); | ||||
| } | ||||
							
								
								
									
										31
									
								
								ft_strstr.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								ft_strstr.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_strstr.c                                        :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 13:39:33 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/26 15:11:03 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "lib_ft.h" | ||||
|  | ||||
| char	*strstr(const char *haystack, const char *needle) | ||||
| { | ||||
| 	int	i; | ||||
|  | ||||
| 	if (!*needle) | ||||
| 		return (haystack); | ||||
| 	while (*haystack) | ||||
| 	{ | ||||
| 		i = 0; | ||||
| 		while (*(haystack + i) == *(needle + i)) | ||||
| 			i++; | ||||
| 		if (!*(haystack + i)) | ||||
| 			return (needle); | ||||
| 		str++; | ||||
| 	} | ||||
| 	return (NULL); | ||||
| } | ||||
							
								
								
									
										20
									
								
								ft_tolower.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ft_tolower.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_tolower.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 13:25:48 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:18:32 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_lower(int c) | ||||
| { | ||||
| 	if (c >= 'A' && 'Z' >= c) | ||||
| 		return (c - 48); | ||||
| 	return (c); | ||||
| } | ||||
							
								
								
									
										20
									
								
								ft_toupper.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ft_toupper.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   ft_toupper.c                                       :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 12:38:07 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 11:04:06 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #include "libft.h" | ||||
|  | ||||
| int	ft_toupper(int c) | ||||
| { | ||||
| 	if (c >= 'a' && 'z' >= c) | ||||
| 		return (c - 48); | ||||
| 	return (c); | ||||
| } | ||||
							
								
								
									
										41
									
								
								libft.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								libft.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| /* ************************************************************************** */ | ||||
| /*                                                                            */ | ||||
| /*                                                        :::      ::::::::   */ | ||||
| /*   libft.h                                            :+:      :+:    :+:   */ | ||||
| /*                                                    +:+ +:+         +:+     */ | ||||
| /*   By: cchauvet <cchauvet@student.42angoulem      +#+  +:+       +#+        */ | ||||
| /*                                                +#+#+#+#+#+   +#+           */ | ||||
| /*   Created: 2022/09/26 14:47:54 by cchauvet          #+#    #+#             */ | ||||
| /*   Updated: 2022/09/27 16:06:28 by cchauvet         ###   ########.fr       */ | ||||
| /*                                                                            */ | ||||
| /* ************************************************************************** */ | ||||
|  | ||||
| #ifndef LIBFT_H | ||||
| # define LIBFT_H | ||||
| # include <stddef.h> | ||||
| # include <stdlib.h> | ||||
|  | ||||
| int		ft_isalpha(int c); | ||||
| int		ft_isdigit(int c); | ||||
| int		ft_isalnum(int c); | ||||
| int		ft_isascii(int c); | ||||
| int		ft_isprint(int c); | ||||
| size_t	ft_strlen(const char *s); | ||||
| /* todo */ | ||||
| void	*ft_memset(void *s, int c, size_t n); | ||||
| void	ft_bzero(void *s, size_t n); | ||||
| void	*ft_memcpy(void *dest, const void *src, size_t n); | ||||
| void	*ft_memmove(void *dest, const void *src, size_t n); | ||||
| size_t	ft_strlcpy(char *dst, const char *src, size_t size); | ||||
| size_t	ft_strlcat(char *dst, const char *src, size_t size); | ||||
| int		ft_toupper(int c); | ||||
| int		ft_tolower(int c); | ||||
| char	*ft_strchr(const char *s, int c); | ||||
| char	*ft_strrchr(const char *s, int c); | ||||
| int		ft_strncmp(const char *s1, const char *s2, size_t n); | ||||
| void	*ft_memchr(const void *s, int c, size_t n); | ||||
| void	*ft_memrchr(const void *s, int c, size_t n); | ||||
| char	*ft_strnstr(const char *big, const char *little, size_t len); | ||||
| int		ft_atoi(const char *nptr); | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user