No description
  • C 98.4%
  • Makefile 1.6%
Find a file
Daniel Petutschnigg d7a3a91054 fix: memmove
2026-05-30 12:39:09 +02:00
ft_atoi.c fix: atoi 2026-05-29 18:51:37 +02:00
ft_bzero.c fix: NULL protection 2026-05-20 21:49:25 +02:00
ft_calloc.c fix compiler errors 2026-05-26 16:53:27 +02:00
ft_isalnum.c WIP 2026-04-20 13:03:33 +02:00
ft_isalpha.c WIP 2026-04-20 13:03:33 +02:00
ft_isascii.c WIP 2026-04-20 13:03:33 +02:00
ft_isdigit.c WIP 2026-04-20 13:03:33 +02:00
ft_isprint.c WIP 2026-04-20 13:03:33 +02:00
ft_itoa.c Fixes 2026-05-29 15:16:22 +02:00
ft_lstadd_back.c fix: part 3 2026-04-30 15:43:33 +02:00
ft_lstadd_front.c fix: part 3 2026-04-30 15:43:33 +02:00
ft_lstclear.c Fixes 2026-05-29 15:26:56 +02:00
ft_lstdelone.c feat: add ft_lstdelone.c 2026-04-22 13:34:20 +02:00
ft_lstiter.c feat: add ft_lstiter.c 2026-04-22 14:19:42 +02:00
ft_lstlast.c feat: add ft_lstlast.c 2026-04-22 13:34:34 +02:00
ft_lstmap.c refactor: cleanup 2026-05-29 14:47:28 +02:00
ft_lstnew.c fix(ft_lstnew) 2026-04-22 13:34:59 +02:00
ft_lstsize.c fix: part 3 2026-04-30 15:43:33 +02:00
ft_memchr.c fix: use size_t where applicable 2026-05-29 11:22:37 +02:00
ft_memcmp.c refactor: cleanup 2026-05-29 14:23:14 +02:00
ft_memcpy.c fix: use size_t where applicable 2026-05-29 11:22:37 +02:00
ft_memmove.c fix: memmove 2026-05-30 12:39:09 +02:00
ft_memset.c fix: use size_t where applicable 2026-05-29 11:22:37 +02:00
ft_putchar_fd.c refactor: norm 2026-04-22 12:56:43 +02:00
ft_putendl_fd.c fix: mhuszar review 2026-05-26 16:24:37 +02:00
ft_putnbr_fd.c fix: putnbr_fd 2026-05-29 19:03:57 +02:00
ft_putstr_fd.c fix: mhuszar review 2026-05-26 16:24:37 +02:00
ft_split.c Fixes 2026-05-29 15:26:56 +02:00
ft_strchr.c fix: remove unnecessary casting 2026-05-30 09:27:45 +02:00
ft_strdup.c fix: remove unnecessary casting 2026-05-30 09:27:45 +02:00
ft_striteri.c fix: use size_t where applicable 2026-05-29 11:22:37 +02:00
ft_strjoin.c fix: remove unnecessary casting 2026-05-30 09:27:45 +02:00
ft_strlcat.c fix: norm 2026-05-21 13:08:59 +02:00
ft_strlcpy.c fix: use size_t where applicable 2026-05-29 11:22:37 +02:00
ft_strlen.c fix: NULL protection 2026-05-20 21:49:25 +02:00
ft_strmapi.c fix: remove unnecessary casting 2026-05-30 09:27:45 +02:00
ft_strncmp.c fix: NULL protection 2026-05-20 21:49:25 +02:00
ft_strnstr.c fix: ghermann eval changes 2026-05-15 13:11:12 +02:00
ft_strrchr.c refactor: cleanup 2026-05-29 14:47:28 +02:00
ft_strtrim.c refactor: cleanup 2026-05-29 14:47:28 +02:00
ft_substr.c fix: remove unnecessary casting 2026-05-30 09:27:45 +02:00
ft_tolower.c WIP 2026-04-20 16:19:57 +02:00
ft_toupper.c WIP 2026-04-20 16:19:57 +02:00
libft.h fix(signatures): const char -> char const (part 2) 2026-05-08 11:23:54 +02:00
Makefile fix: Makefile 2026-05-29 11:08:58 +02:00
README.md fix: README 2026-05-29 11:15:09 +02:00

This project has been created as part of the 42 curriculum by dpetutsc.

Libft

Description

In the libft project I was tasked to build common useful functions in C in order to gain understanding of their inner workings and to enable me to use them again without having to rewrite them all the time in future projects.

I have decided to guard all function parameters against NULL pointers since the stdlib && bsd-lib are inconsistent in this regard and it seems better to have UB be guarded NULL pointers rather than running the risk of missing the odd case in the stdlib where NULL is guarded.

It includes the following functions:

int ft_isalpha(int c)

Checks whether the given int is an alphabetical character.

int ft_isdigit(int c)

Checks whether the given int is a digit character.

int ft_isalnum(int c)

Checks whether the given int is an alphanumerical character.

int ft_isascii(int c)

Checks whether the given int is an ascii character.

int ft_isprint(int c)

Checks whether the given int is a printable character.

size_t ft_strlen(const char *s)

Returns the length of the given string literal.

void *ft_memset(void *s, int c, size_t n)

Fills the given void buffer with n times charcter c.

void ft_bzero(void *s, size_t n)

Fills the given void buffer with n empty bytes (0).

void *ft_memcpy(void *dest, void *src, size_t n)

Copys the first n bytes of src into void.

void *ft_memmove(void *dest, void *src, size_t n)

Copys the first n bytes of src into void and insures that the operation succeeds if dest and src overlap.

size_t ft_strlcat(char *dest, const char *src, size_t size)

Concatinates up to size chars of src onto dest.

size_t ft_strlcpy(char *dst, const char *src, size_t size)

Copys size chars of src int dest.

int ft_toupper(int c)

Converts lowercase chars into uppercase chars (if applicable).

int ft_tolower(int c)

Converts uppercase chars into lowercase chars (if applicable).

char *ft_strchr(const char *s, int c)

Finds the first occurance of c in s.

char *ft_strrchr(const char *s, int c)

Finds the last occurance of c in s.

int ft_strncmp(const char *s1, const char *s2, size_t n)

Compares the first n chars of s1 and s2. Returns positive value if first n chars of s1 > s2, negative if s2 > s1 and 0 if s1 == s2.

void *ft_memchr(const void *s, int c, size_t n)

Finds the first occurance of c in s.

int ft_memcmp(const void *s1, const void *s2, size_t n)

Compares the first n chars of s1 and s2. Returns positive value if first n chars of s1 > s2, negative if s2 > s1 and 0 if s1 == s2.

char *ft_strnstr(const char *big, const char *little, size_t len)

Finds and returns the address of the start of little within big.

int ft_atoi(const char *nptr)

Converts ascii to integers (if applicable as described in the manual).

void *ft_calloc(size_t nmemb, size_t size)

Allocates nmemb * size memory and fills it with empty values (0).

char *ft_strdup(const char *s)

Copies s into a newly allocated string.

char *ft_substr(const char *s, unsigned int start, size_t len)

Copies len chars starting after start into a newly allocated string.

char *ft_strjoin(const char *s1, const char *s2)

Joins 2 strings together into one. ("Hello", "World" --> "HelloWorld")

char *ft_strtrim(const char *s1, const char *set)

Trims all chars in set from the beginning and end of s1.

char **ft_split(const char *s, char c)

Splits s into multiple strings at the provided c.

char *ft_itoa(int n)

Converts an integer into its ascii representation (string).

char *ft_strmapi(char const *s, char (*f)(unsigned int, char))

Applies f to each char of c and returns a newly allocated resulting string.

void ft_striteri(char *s, void (*f)(unsigned int, char *))

Applies f to each char of c modifying the inputed s.

void ft_putchar_fd(char c, int fd)

Writes a char to provided filedescriptor.

void ft_putstr_fd(char *s, int fd)

Writes a string to provided filedescriptor.

void ft_putendl_fd(char *s, int fd)

Writes a string and a newline to provided filedescriptor.

void ft_putnbr_fd(int n, int fd)

Writes a integer as ascii to the provided filedescriptor.

t_list *ft_lstnew(void *content)

Allocates a new t_list list-node and returns the pointer to it.

void ft_lstadd_front(t_list **lst, t_list *new)

Adds a t_list node to the beginning of the provided linked-list lst.

int ft_lstsize(t_list *lst)

Returns the number of nodes in the provided list.

t_list *ft_lstlast(t_list *lst)

Returns the last element is the provided list.

void ft_lstadd_back(t_list **lst, t_list *new)

Adds a t_list node to the end of the provided linked-list lst.

void ft_lstdelone(t_list *lst, void (*del)(void *))

Deletes a t_list listnode using the provided del function.

void ft_lstclear(t_list **lst, void (*del)(void *))

Deletes and frees the given list (node and all following nodes).

void ft_lstiter(t_list *lst, void (*f)(void *))

Iterates throuhg a list and applies f() to each node.

t_list *ft_lstmap(t_list *lst, void *(*f)(void *),void (*del)(void *))

Iterates though lst and applies f to the content of each node and creates a new list with the result.

Instructions

In order to create a static library out of the provided .c files make, make all or make libft.a is used (all 3 do the same thing). Also provided are the shortcuts make clean, make fclean, make re.

Resources

AI was not used to generate anything within this project. It has been used in addition with search engines (google, duckduckgo) to attain information.