This project is a fundamental exploration into the world of C programming, requiring you to create My own C library known as "libft." The library comprises a collection of general-purpose functions, mimicking some of the standard functions found in the C library. This initiative aims to enhance My understanding of how these functions operate, encouraging you to implement and utilize them. Not only will this library serve as a valuable tool for future C assignments, but it will also deepen My grasp of low-level programming concepts.
-
ft_isalpha
- Description: Check if a character is an alphabetic character.
- Prototype:
int ft_isalpha(int c);
-
ft_isdigit
- Description: Check if a character is a digit (0-9).
- Prototype:
int ft_isdigit(int c);
-
ft_isalnum
- Description: Check if a character is alphanumeric.
- Prototype:
int ft_isalnum(int c);
-
ft_isascii
- Description: Check if a character is a 7-bit ASCII character.
- Prototype:
int ft_isascii(int c);
-
ft_isprint
- Description: Check if a character is a printable character.
- Prototype:
int ft_isprint(int c);
-
ft_strlen
- Description: Calculate the length of a string.
- Prototype:
size_t ft_strlen(const char *s);
-
ft_memset
- Description: Fill memory with a constant byte.
- Prototype:
void *ft_memset(void *s, int c, size_t n);
-
ft_bzero
- Description: Set the first n bytes of the memory area pointed to by s to zero.
- Prototype:
void ft_bzero(void *s, size_t n);
-
ft_memcpy
- Description: Copy memory area.
- Prototype:
void *ft_memcpy(void *dest, const void *src, size_t n);
-
ft_memmove
- Description: Copy memory area, handling overlapping memory regions.
- Prototype:
void *ft_memmove(void *dest, const void *src, size_t n);
- ft_strlcpy
- Description: Copy strings with source and destination size control.
- Prototype:
size_t ft_strlcpy(char *dest, const char *src, size_t size);
- ft_strlcat
- Description: Concatenate strings with source and destination size control.
- Prototype:
size_t ft_strlcat(char *dest, const char *src, size_t size);
- ft_toupper
- Description: Convert a lowercase letter to its corresponding uppercase letter.
- Prototype:
int ft_toupper(int c);
- ft_tolower
- Description: Convert an uppercase letter to its corresponding lowercase letter.
- Prototype:
int ft_tolower(int c);
- ft_strchr
- Description: Locate the first occurrence of a character in a string.
- Prototype:
char *ft_strchr(const char *s, int c);
- ft_strrchr
- Description: Locate the last occurrence of a character in a string.
- Prototype:
char *ft_strrchr(const char *s, int c);
- ft_strncmp
- Description: Compare two strings up to a specified number of characters.
- Prototype:
int ft_strncmp(const char *s1, const char *s2, size_t n);
- ft_memchr
- Description: Locate the first occurrence of a character in a memory block.
- Prototype:
void *ft_memchr(const void *s, int c, size_t n);
- ft_memcmp
- Description: Compare two memory blocks.
- Prototype:
int ft_memcmp(const void *s1, const void *s2, size_t n);
- ft_strnstr
- Description: Locate a substring in a string, but with a specified maximum length.
- Prototype:
char *ft_strnstr(const char *haystack, const char *needle, size_t len);
- ft_atoi
- Description: Convert a string to an integer.
- Prototype:
int ft_atoi(const char *str);
-
ft_substr
- Description: Allocate and return a substring from a given string.
- Prototype:
char *ft_substr(char const *s, unsigned int start, size_t len);
-
ft_strjoin
- Description: Concatenate two strings into a new string.
- Prototype:
char *ft_strjoin(char const *s1, char const *s2);
-
ft_strtrim
- Description: Allocate and return a trimmed version of a string.
- Prototype:
char *ft_strtrim(char const *s1, char const *set);
-
ft_split
- Description: Split a string into an array of substrings based on a delimiter.
- Prototype:
char **ft_split(char const *s, char c);
-
ft_itoa
- Description: Convert an integer to a string.
- Prototype:
char *ft_itoa(int n);
-
ft_strmapi
- Description: Apply a function to each character of a string, creating a new string.
- Prototype:
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
-
ft_striteri
- Description: Apply a function to each character of a string with its index as an argument.
- Prototype:
void ft_striteri(char *s, void (*f)(unsigned int, char*));
-
ft_putchar_fd
- Description: Output a character to a specified file descriptor.
- Prototype:
void ft_putchar_fd(char c, int fd);
-
ft_putstr_fd
- Description: Output a string to a specified file descriptor.
- Prototype:
void ft_putstr_fd(char *s, int fd);
-
ft_putendl_fd
- Description: Output a string followed by a newline to a specified file descriptor.
- Prototype:
void ft_putendl_fd(char *s, int fd);
- ft_putnbr_fd
- Description: Output an integer to a specified file descriptor.
- Prototype:
void ft_putnbr_fd(int n, int fd);
To represent a node of the linked list, the following structure is used. Add its declaration to your libft.h
file:
typedef struct s_list
{
void *content;
struct s_list *next;
} t_list;
-
ft_lstnew
- Description: Create a new node with the specified content.
- Prototype:
t_list *ft_lstnew(void *content);
-
ft_lstadd_front
- Description: Add a new node at the beginning of a linked list.
- Prototype:
void ft_lstadd_front(t_list **lst, t_list *new);
-
ft_lstsize
- Description: Count the number of nodes in a linked list.
- Prototype:
int ft_lstsize(t_list *lst);
-
ft_lstlast
- Description: Retrieve the last node of a linked list.
- Prototype:
t_list *ft_lstlast(t_list *lst);
-
ft_lstadd_back
- Description: Add a new node at the end of a linked list.
- Prototype:
void ft_lstadd_back(t_list **lst, t_list *new);
-
ft_lstdelone
- Description: Delete a node from a linked list.
- Prototype:
void ft_lstdelone(t_list *lst, void (*del)(void *));
-
ft_lstclear
- Description: Delete and free a linked list.
- Prototype:
void ft_lstclear(t_list **lst, void (*del)(void *));
-
ft_lstiter
- Description: Apply a function to each node of a linked list.
- Prototype:
void ft_lstiter(t_list *lst, void (*f)(void *));
-
ft_lstmap
- Description: Create a new list by applying a function to each node of an existing list.
- Prototype:
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));