This project is about coding a C library.
It will contain a lot of general purpose functions your programs will rely upon.
This is the first project of the common core at 42 São Paulo. The project wants that you recode some functions from C Library and other useful functions that you could use in your future projects.
Important
I have a new version of libft that contains the libft, get_next_line and ft_printf functions in the same project.
You could access it with the link bellow:
New libft version: libftx
Clone the repository to your project directory:
git clone https://github.com/rgrmra/libft.git libft
Then use the command make
inside the libft directory to build the compiled libft archive of the mandatory part of the project.
If you need the bonus part, use the command make bonus
to include the bonus functions in the libft archive.
To remove the objects compiled, use the command make clean
.
And, if you want to delete everything, use the command make fclean
.
To use the functions of the library you need to include it in your project and compile your project with the libft archive.
#include "libft.h"
gcc main.c -I ./libft ./libft/libft.a
- libft.h - forty-two standard library
#include "libft.h"
The "libft.h" headers defines the folowing:
size_t
Unsigned integral type of the result of the sizeof operator. As described in <stddef.h>.
t_list
Linked list structure that provides the folowing filds:
void *content;
struct s_list next;
The following are declared as functions and may also be defined as macros. Function prototypes must be provided for use with an ISO C compiler.
ft_atoi
Converts the initial portion of the string containing numeric characters to integer.
int ft_atoi(const char *nptr);
ft_bzero
Erase all bytes of the memory required with zero.
void ft_bzero(void *s, size_t n);
ft_calloc
Alloc a required space of memory and sets all bytes to zero.
void *ft_calloc(size_t nmemb, size_t size);
ft_isascii
Checks whether character is a 7-bit US-ASCII character code.
int ft_isascii(int i);
ft_lstadd_back (bonus)
Append a new node to the end of a list.
void ft_lstadd_back(t_list **lst, t_list *new);
ft_lstadd_front (bonus)
Append a new node to the begin of a list.
void ft_lstadd_front(t_list **lst, t_list *new);
ft_lstclear (bonus)
Erases all content and nodes of a list.
void ft_lstclear(t_list **lst, void (*del)(void *));
ft_lstdelone (bonus)
Deletes one node of a list.
void ft_lstdelone(t_list *lst, void (*del)(void *));
ft_lstiter (bonus)
Applies a function to each content of a node of a list.
void ft_lstiter(t_list *lst, void (*f)(void *));
ft_lstmap (bonus)
Returns a new list applying a required function to each node of the list.
t_list ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
ft_memchr
Finds the first required byte in an area pointed in the memory.
void *ft_memchr(const void *s, int c, size_t n);
ft_memcmp
Compares the amount of bytes between two areas pointed in the memory.
int ft_memcmp(const void *s1, const void *s2, size_t n);
ft_memcpy
Copies the required amount of bytes from an area to another area pointed in the memory.
void *ft_memcpy(void *dest, const void *src, size_t n);
ft_memmove
Moves an requried amount of bytes from an area to another area pointed in the memory.
void *ft_memmove(void *dest, const void *src, size_t n);
ft_memset
Sets all bytes required in the memory area pointed with the byte informed.
void *ft_memset(void *s, int c, size_t n);
ft_putchar_fd
Prints a char in the required filedescriptor.
void ft_putchar_fd(char c, int fd);
ft_putendl_fd
Prints a string followed by a new line in the required filedescriptor.
void ft_putendl_fd(char *s, int fd);
ft_putnbr_fd
Prints a integer number in the required filedescriptor.
void ft_putnbr_fd(int n, int fd);
ft_putstr_fd
Prints a string in the required filedescriptor.
void ft_putstr_fd(char *s, int fd);
ft_split
Splits a constant string into an allocated array of strings containg the words splited by the required separator.
char **ft_split(const char *s, char c);
ft_strchr
Finds the first required character in a constant string.
char *ft_strchr(const char *s, int c);
ft_striteri
Iterates a function to each character of a string.
void ft_striteri(char *s, void (*f)(unsigned int, char *));
ft_strjoin
Concatenates a new string containg the two strings informed.
char *ft_strjoin(const char *s1, const char *s2);
ft_strlcat
Concatemates a string to another string informed.
size_t ft_strlcat(char *dest, char *src, size_t size);
ft_strlcpy
Copies the content of a string to another string informed.
size_t ft_strlcpy(char *dest, char *src, size_t size);
ft_strmapi
Duplicates a new string and applies a function to each character of the string.
char *ft_strmapi(const char *s, char (*f)(unsigned int, char));
ft_strncmp
Compares two strings.
int ft_strncmp(const char *s1, const char *s2, size_t n);
ft_strrchr
Finds the last required character in a constant string.
char *ft_strrchr(const char *s, int c);
ft_strtrim
Removes the amount of required characters in the begin and end of the string.
char *ft_strtrim(const char *s1, const char *set);
ft_substr
Generates a sub new string from a required string.
char *ft_substr(const char *s, unsigned int start, size_t len);
- Inclusion of "libft.h" header may also make visible all symbols from <stddef.h> and <stdlib.h>.
- None
- None