Skip to content
/ libft Public

42 Cursus - Libft: My implementation of some useful C functions and some additional ones to use it in future projects of 42.

License

Notifications You must be signed in to change notification settings

izenynn/libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42 Cursus - libft

Info

My implementation of some useful C functions and some additional ones to use it in future projects of 42.

  • Status: still updating (I use libft a lot so I keep improving it)
  • Result: 125%
  • Observations: (null)

How to install and use

  • Clone libft into your project folder
git clone https://github.com/izenynn/libft.git
  • Run make inside libft folder (make rules: all, clean, fclean, re)
make
  • Include libft.h in the header of your C file
#include <libft.h>
  • Or include only the part that you are going to use (list of functions below)
#include <libft/ft_char.h>
#include <libft/ft_str.h>
#include <libft/ft_mem.h>
#include <libft/ft_nbr.h>
#include <libft/ft_fd.h>
#include <libft/ft_lst.h>
#include <libft/ft_dlst.h>
#include <libft/ft_printf.h>

How to compile with libft

Compile directly your .c files

  • Just make sure you add libft (libft.a) and you specify libft.h path (-I flag) when you compile
gcc (...)(.c files) -o (output file) ./libft/libft.a -I ./libft/inc

Compile objects (.o) (for Makefiles)

  • If you want to compile firts your .c files into .o, you will need to specify the -c flag (no linking) when compiling to .o files, and indicate the libft.h path with the -I flag
gcc -c (.c file) -o (.o output file) -I ./libft/inc
  • Now we will compile all the .o into a program, and do the linking part with -L and -l, just specify the libft.a path with the -L flag
gcc (...)(.o files) -o (output file) -I ./libft/inc -L ./libft -lft
  • ✨ Magic ✨

List of functions

ft_char

ft_str

  • ft_strlen - size_t ft_strlen(const char *s
  • ft_strcpy - char *ft_strcpy(char *dst, const char *src)
  • ft_strlcpy - size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
  • ft_strcat - char *ft_strcat(char *s1, const char *s2)
  • ft_strlcat - size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
  • ft_strchr - char *ft_strchr(const char *s, int c)
  • ft_strrchr - char *ft_strrchr(const char *s, int c)
  • ft_strcmp - int ft_strcmp(const char *s1, const char *s2)
  • ft_strncmp - int ft_strncmp(const char *s1, const char *s2, size_t n)
  • ft_strnstr - char *ft_strnstr(const char *haystack, const char *needle, size_t len)
  • ft_strdup - char *ft_strdup(const char *s1)
  • ft_substr - char *ft_substr(const char *s, unsigned int start, size_t len)
  • ft_strjoin - char *ft_strjoin(const char *s1, const char *s2)
  • ft_strtrim - char *ft_strtrim(const char *s1, const char *set)
  • ft_split - char **ft_split(const char *s1, const char *set)
  • ft_strmap - char *ft_strmap(const char *s, char (*f)(char))
  • ft_strmapi - char *ft_strmapi(const char *s, char (*f)(unsigned int, char))
  • ft_striter - void ft_striter(char *s, void (*f)(char *))
  • ft_striteri - void ft_striteri(char *s, void (*f)(unsigned int, char *))
  • ft_strrev - char *ft_strrev(char *s)

ft_mem

  • ft_memset
  • ft_bzero
  • ft_memcpy
  • ft_memmove
  • ft_memchr
  • ft_memcmp
  • ft_calloc
  • ft_realloc

ft_nbr

  • ft_atoi
  • ft_itoa
  • ft_atoi_base
  • ft_itoa_base
  • ft_convert_base
  • ft_intlen
  • ft_intlen_base
  • ft_uintlen
  • ft_uintlen_base
  • ft_ulonglen
  • ft_ulonglen_base

ft_fd

  • ft_putchar_fd
  • ft_putstr_fd
  • ft_putendl_fd
  • ft_putnbr_fd
  • ft_putmem_fd
  • ft_get_next_line

ft_lst

  • ft_lstnew
  • ft_lstadd_front
  • ft_lstadd_back
  • ft_lstsize
  • ft_lstlast
  • ft_lstdelone
  • ft_lstclear
  • ft_lstiter
  • ft_lstmap

ft_dlst

  • ft_dlstnew
  • ft_dlstadd_front
  • ft_dlstadd_back
  • ft_dlstsize
  • ft_dlstfirst
  • ft_dlstlast
  • ft_dlstdelone
  • ft_dlstclear
  • ft_dlstiter
  • ft_dlstmap

ft_printf

  • ft_printf
  • ft_dprintf

ft_printf flags

  • %c print a single character.
  • %s print a string of characters.
  • %p the void * pointer argument is printed in hexadecimal.
  • %d print a decimal (base 10) number.
  • %i print an integer in base 10.
  • %u print an unsigned decimal (base 10) number
  • %x print a number in hexadecimal (base 16) with lowercase.
  • %X print a number in hexadecimal (base 16) with uppercase.
  • %% print a percent sign.
  • - left-justify within the given field width; Right justification is the default.
  • 0 left-pads the number with zeroes (0) instead of spaces when padding is specified.
  • . the precision in not specified in the format string, but as an additional integer value argument preceding the argument that has to be formated.
  • # used with x or X specifiers the value is preceeded with 0x or 0X respectively for the values different than zero.
  • (space) if no sign is going to be written, a blank space is inserted before the value.
  • + forces to preceed the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign.

forthebadge forthebadge