School 21 (Ecole 42) project. The aim of this project is to code a C library regrouping usual functions.
- ft_memset
- ft_bzero
- ft_memcpy
- ft_memccpy
- ft_memmove
- ft_memchr
- ft_memcmp
- ft_strlen
- ft_strdup
- ft_strcpy
- ft_strncpy
- ft_strcat
- ft_strncat
- ft_strlcat
- ft_strchr
- ft_strrchr
- ft_strstr
- ft_strnstr
- ft_strcmp
- ft_strncmp
- ft_atoi
- ft_isalpha
- ft_isdigit
- ft_isalnum
- ft_isascii
- ft_isprint
- ft_toupper
- ft_tolower
Name | Prototype | Description |
---|---|---|
ft_memalloc | void *ft_memalloc(size_t size) | Allocates (with malloc(3)) and returns a "fresh" memory area. The memory allocated is initialized to 0. If the allocation fails, the function returns NULL. |
ft_memdel | void ft_memdel(void **ap) | Takes as a parameter the address of a memory area that needs to be freed with free(3), then puts the pointer to NULL. |
ft_strnew | char *ft_strnew(size_t size) | Allocates (with malloc(3)) and returns a "fresh" string ending with '\0'. Each character of the string is initialized at '\0'. If the allocation fails the function returns NULL. |
ft_strdel | void ft_strdel(char **as) | Takes as a parameter the address of a string that need to be freed with free(3), then sets its pointer to NULL. |
ft_strclr | void ft_strclr(char *s) | Sets every character of the string to the value '\0'. |
ft_striter | void ft_striter(char *s, void (*f)(char *)) | Applies the function f to each character of the string passed as argument. Each character is passed by address to f to bemodified if necessary. |
ft_striteri | void ft_striteri(char *s, void (*f)(unsigned int, char *) | Applies the function f to each character of the string passed as argument, and passing its index as first argument. Each character is passed by address to f to be modified if necessary. |
ft_strmap | char *ft_strmap(char const *s, char (*f)(char)) | Applies the function f to each character of the string given as argument to create a "fresh" new string (with malloc(3)) resulting from the successive applications of f. |
ft_strmapi | char *ft_strmapi(char const *s, char(*f)(unsigned int, char)) | Applies the function f to each character of the string passed as argument by giving its index as first argument to create a "fresh" new string (with malloc(3)) resulting from the successive applications of f. |
ft_strequ | int ft_strequ(char const *s1, char const *s2) | Lexicographical comparison between s1 and s2. If the 2 strings are identical the function returns 1, or 0 otherwise. |
ft_strnequ | int ft_strnequ(char const *s1, char const *s2, size_t n) | Lexicographical comparison between s1 and s2 up to n characters or until a '\0' is reached. If the 2 strings are identical, the function returns 1, or 0 otherwise. |
ft_strsub | char *ft_strsub(char const *s, unsigned int start, size_t len) | Allocates (with malloc(3)) and returns a "fresh" substring from the string given as argument. The substring begins at index start and is of size len. If start and len aren't refering to a valid substring, the behavior is undefined. If the allocation fails, the function returns NULL. |
ft_strjoin | char *ft_strjoin(char const *s1, char const *s2) | Allocates (with malloc(3)) and returns a "fresh" string ending with '\0', result of the concatenation of s1 and s2. If the allocation fails the function returns NULL. |
ft_strtrim | char *ft_strtrim(char const *s) | Allocates (with malloc(3)) and returns a copy of the string given as argument without whitespaces at the beginning or at the end of the string. Will be considered as whitespaces the following characters ' ', '\n' and '\t'. If s has no whitespaces at the beginning or at the end, the function returns a copy of s. If the allocation fails the function returns NULL. |
ft_strsplit | char **ft_strsplit(char const *s, char c) | Allocates (with malloc(3)) and returns an array of "fresh" strings (all ending with '\0', including the array itself) obtained by spliting s using the character c as a delimiter. If the allocation fails the function returns NULL. Example: ft_strsplit("*hello*fellow***students*", '*') returns the array ["hello", "fellow", "students"]. |
ft_itoa | char *ft_itoa(int n) | Allocate (with malloc(3)) and returns a "fresh" string ending with '\0' representing the integer n given as argument. Negative numbers must be supported. If the allocation fails, the function returns NULL. |
ft_putchar | void ft_putchar(char c) | Outputs the character c to the standard output. |
ft_putstr | void ft_putstr(char const *s) | Outputs the string s to the standard output. |
ft_putendl | void ft_putendl(char const *s) | Outputs the string s to the standard output followed by a '\n'. |
ft_putnbr | void ft_putnbr(int n) | Outputs the integer n to the standard output. |
ft_putchar_fd | void ft_putchar_fd(char c, int fd) | Outputs the char c to the file descriptor fd. |
ft_putstr_fd | void ft_putstr_fd(char const *s, int fd) | Outputs the string s to the file descriptor fd. |
ft_putendl_fd | void ft_putendl_fd(char const *s, int fd) | Outputs the string s to the file descriptor fd followed by a '\n'. |
ft_putnbr_fd | void ft_putnbr_fd(int n, int fd) | Outputs the integer n to the file descriptor fd. |