In this first part, you must re-code a set of the libc functions, as defined in their man. Your functions will need to present the same prototype and behaviors as the originals. Your functions’ names must be prefixed by “ft_”. For instance strlen becomes ft_strlen.
• isalpha • isdigit • isalnum • isascii • isprint • strlen • memset • bzero • memcpy • memmove • strlcpy • strlcat • toupper • tolower • strchr • strrchr • strncmp • memchr • memcmp • strnstr • atoi
In this second part, you must code a set of functions that are either not included in the libc, or included in a different form. Some of these functions can be useful to write Part 1’s functions.
• substr • strjoin • strtrim • split • itoa • strmapi • striteri • putchar_fd • putstr_fd • putendl_fd • putnbr_fd
The following functions will allow you to easily use your lists.
• lstnew • lstadd_front • lstsize • lstlast • lstadd_back • lstdelone • lstclear • lstiter • lstmap
ft_isalpha
- checks for an alphabetic characterft_isdigit
- checks for a digit (0 through 9).ft_isalnum
- checks for an alphanumeric characterft_isascii
- checks whether c fits into the ASCII character setft_isprint
- checks for any printable characterft_toupper
- convert char to uppercaseft_tolower
- convert char to lowercase
ft_memset
- fill memory with a constant byteft_strlen
- calculate the length of a stringft_bzero
- zero a byte stringft_memcpy
- copy memory areaft_memmove
- copy memory areaft_strlcpy
- copy string to an specific sizeft_strlcat
- concatenate string to an specific sizeft_strchr
- locate character in stringft_strrchr
- locate character in stringft_strncmp
- compare two stringsft_memchr
- scan memory for a characterft_memcmp
- compare memory areasft_strnstr
- locate a substring in a stringft_strdup
- creates a dupplicate for the string passed as parameter
ft_atoi
- convert a string to an integerft_calloc
- allocates memory and sets its bytes' values to 0
ft_substr
- returns a substring from a stringft_strjoin
- concatenates two stringsft_strtrim
- trims the beginning and end of string with specific set of charsft_split
- splits a string using a char as parameterft_itoa
- converts a number into a stringft_strmapi
- applies a function to each character of a stringft_striteri
- applies a function to each character of a stringft_putchar_fd
- output a char to a file descriptorft_putstr_fd
- output a string to a file descriptorft_putendl_fd
- output a string to a file descriptor, followed by a new lineft_putnbr_fd
- output a number to a file descriptor
ft_lstnew
- creates a new list elementft_lstadd_front
- adds an element at the beginning of a listft_lstsize
- counts the number of elements in a listft_lstlast
- returns the last element of the listft_lstadd_back
- adds an element at the end of a listft_lstclear
- deletes and free listft_lstiter
- applies a function to each element of a listft_lstmap
- applies a function to each element of a list
libft
requires a gcc compiler and some standard libraries.
Clone this repository in your local computer:
$> git clone https://github.com/caroldaniel/42sp-cursus_libft.git path/to/libft
In your local repository, run make
$> make
make
suports 6 flags:
make all
or simplymake
compiles only the mandatory functionsmake bonus
compiles the bonus functionsmake clean
deletes the.o
files generated during compilationmake fclean
deletes the.o
and thelibft.a
library file generatedmake re
executesfclean
andall
in sequence, recompiling the library without the bonus functionsmake rebonus
executesfclean
andbonus
in sequence, recompiling the library with the bonus functions
To use the library in your code you will need to include the header:
#include "libft.h"
When compiling your own code with libft
, don't forget to use the flags:
$> ... -lft -L path/to/libft.a -I path/to/libft.h