Personalized function library based on standard 🇨 library.
Library includes mainly a selection of replicated Libc functions.
It is complemented by additional, mostly string and print based functionality.
Bonus which is centered around linked lists is also integrated into the library.
ft_printf and gnl are combined to the project as well alongside other extra functions.
Project passes many of the 42 testers, including franzinette strict.
Main branch is shared between other 42 projects and it is expanded from original subject.
If you want to see the version used for school evaluation, check eval branch.
GNU make, gcc and ar are required to build, compile and archive the project.
git clone https://github.com/Jarnomer/libft.gitcd libft && make allBuild creates binary libft.a into root directory and it should be compiled with your project.
#include "./include/libft.h"
int main(void)
{
char *str1 = "Hello ";
char *str2 = "world!";
char *result;
result = ft_strjoin(str1, str2);
ft_printf("Result: %s\n", result);
ft_free_single(&result);
return (0);
}gcc main.c libft.a -o my_programHere is an example how to implement libft into your Makefile.
$(NAME): $(OBJECTS)
$(CC) $(CFLAGS) $^ $(LIBFTDIR)/$(LIBFTBIN) -o $@
$(OBJECTS): $(LIBFTDIR)/$(LIBFTBIN)
libft: $(LIBFTDIR)/$(LIBFTBIN)
$(LIBFTDIR)/$(LIBFTBIN):
@make -C $(LIBFTDIR) allHere is the table of all functions.
| Libc | Additional | Bonus | Extras |
|---|---|---|---|
ft_atoi |
ft_itoa |
ft_lstadd_back |
ft_printf |
ft_bzero |
ft_putchar_fd |
ft_lstadd_front |
ft_printf_fmt |
ft_calloc |
ft_putendl_fd |
ft_lstclear |
ft_gnl |
ft_isalnum |
ft_putnbr_fd |
ft_lstdelone |
ft_gnl_utils |
ft_isalpha |
ft_putstr_fd |
ft_lstiter |
ft_free_single |
ft_isascii |
ft_split |
ft_lstlast |
ft_free_double |
ft_isdigit |
ft_strdup |
ft_lstmap |
ft_strcmp |
ft_isprint |
ft_striteri |
ft_lstnew |
ft_isspace |
ft_memchr |
ft_strjoin |
ft_lstsize |
ft_issign |
ft_memcmp |
ft_strmapi |
||
ft_memcpy |
ft_strtrim |
||
ft_memmove |
ft_substr |
||
ft_memset |
|||
ft_strchr |
|||
ft_strlcat |
|||
ft_strlcpy |
|||
ft_strlen |
|||
ft_strncmp |
|||
ft_strnstr |
|||
ft_strrchr |
|||
ft_tolower |
|||
ft_toupper |
Each function is relying on each other when applicable.
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
int buffer_size;
if (!s1 || !s2)
return (NULL);
buffer_size = ft_strlen(s1) + ft_strlen(s2) + 1;
str = ft_calloc(buffer_size, sizeof(char));
if (!str)
return (NULL);
ft_strlcat(str, s1, buffer_size);
ft_strlcat(str, s2, buffer_size);
return (str);
}franzinette amazing unit test framework for libft and other 42 projects.
For my other 42 projects and general information, please refer the Hive42 page.
I have also created error handling unit testers for pipex, so_long and cub3D.
