Skip to content

In the beginning, there was a tale waiting to unfold... ๐Ÿ“–

Notifications You must be signed in to change notification settings

maitreverge/libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ SYNOPSIS

The libft project is the very first project at 42 school.

It is a foundational coding endeavor where students are tasked with recreating a library of standard C functions from scratch.

This project serves as a crucial introduction to programming concepts and the C language, requiring students to implement fundamental functions such as string manipulation, memory allocation, and basic I/O operations.

Successfully completing the libft project not only demonstrates mastery of these fundamental functions, but also lays the groundwork for subsequent challenges in the 42 curriculum.

-----------------------------------------------------

๐Ÿ—ƒ๏ธ FUNCTIONS LIST

PART 1 (24 / 24) Prototype
ft_atoi int ft_atoi(const char *str);
ft_bzero void ft_bzero(void *s, size_t n);
ft_calloc void *ft_calloc(size_t count, size_t size);
ft_isalnum int ft_isalnum(int c);
ft_isalpha int ft_isalpha(int c);
ft_isascii int ft_isascii(int c);
ft_isdigit int ft_isdigit(int c);
ft_isprint int ft_isprint(int c);
ft_memccpy void *ft_memccpy(void *dst, const void *src, int c, size_t n);
ft_memchr void *ft_memchr(const void *s, int c, size_t n);
ft_memcmp int ft_memcmp(const void *s1, const void *s2, size_t n);
ft_memcpy void *ft_memcpy(void *dest, const void *src, size_t n);
ft_memmove void *ft_memmove(void *dst, const void *src, size_t len);
ft_memset void *ft_memset(void *b, int c, size_t len);
ft_strchr char *ft_strchr(const char *s, int c);
ft_strdup char *ft_strdup(const char *s1);
ft_strlcat size_t ft_strlcat(char *dst, const char *src, size_t dstsize);
ft_strlcpy size_t ft_strlcpy(char *dst, const char *src, size_t dstsize);
ft_strlen size_t ft_strlen(const char *s);
ft_strncmp int ft_strncmp(const char *s1, const char *s2, size_t n);
ft_strnstr char *ft_strnstr(const char *haystack, const char *needle, size_t len);
ft_strrchr char *ft_strrchr(const char *s, int c);
ft_tolower int ft_tolower(int c);
ft_toupper int ft_toupper(int c);
PART 2 (11 / 11) Prototype
ft_itoa char *ft_itoa(int n);
ft_putchar_fd void ft_putchar_fd(char c, int fd);
ft_putendl_fd void ft_putendl_fd(char *s, int fd);
ft_putnbr_fd void ft_putnbr_fd(int n, int fd);
ft_putstr_fd void ft_putstr_fd(char *s, int fd);
ft_split char **ft_split(char const *s, char c);
ft_strjoin char *ft_strjoin(char const *s1, char const *s2);
ft_strmapi char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
ft_strtrim char *ft_strtrim(char const *s1, char const *set);
ft_substr char *ft_substr(char const *s, unsigned int start, size_t len);
ft_striteri void ft_striteri(char *s, void (*f)(unsigned int, char*));
Bonus Functions (9 / 9) Prototype
ft_lstadd_back void ft_lstadd_back(t_list **lst, t_list *new);
ft_lstadd_front void ft_lstadd_front(t_list **lst, t_list *new);
ft_lstclear void ft_lstclear(t_list **lst, void (*del)(void *));
ft_lstdelone void ft_lstdelone(t_list *lst, void (*del)(void *));
ft_lstiter void ft_lstiter(t_list *lst, void (*f)(void *));
ft_lstlast t_list *ft_lstlast(t_list *lst);
ft_lstmap t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
ft_lstnew t_list *ft_lstnew(void *content)
ft_lstsize int ft_lstsize(t_list *lst);

-----------------------------------------------------

โš™๏ธ USAGE

Step 1 :

Run in your shell environment :

git clone https://github.com/maitreverge/libft.git libft

Step 2 :

Enter into the cloned repo :

cd libft

and run :

make all bonus

You'll end up with a file called libft.a, which is a static library.

Step 3 :

Now you can import this libft.a and the libft.h files at the root of your own project, and use the functions linked to it.

Do do so, let's write an simple program called test.c :

// Includes header from the libft
#include "libft.h"

int main(void)
{
    // ft_putstr_fd takes a string and a file descriptor as an input
    ft_putstr_fd("Hello World !\n", 1);

    return (0);
}

Step 4 :

Once the three files libft.a libft.h and test.c are here, run :

gcc libft.a test.c -o program && ./program

This command will compile your test.c and link it to the static library libft.a.

We end up with a file called program, once executed gives :

Hello, World !

๐Ÿค CONTRIBUTION

Contributions are open, make a pull request or open an issue ๐Ÿš€

About

In the beginning, there was a tale waiting to unfold... ๐Ÿ“–

Topics

Resources

Stars

Watchers

Forks