Skip to content

This project aims to code a C library regrouping usual functions to use in future projects.

Notifications You must be signed in to change notification settings

vinifm/42_libft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42_libft

About

Summary: This project aims to code a C library regrouping usual functions that you’ll be allowed to use in all your other projects

Function prototypes and descriptions - Part 1

<ctype.h> library.

<string.h> library.

  • char *ft_strchr(const char *str, int c) - locates character in string.

  • char *ft_strrchr(const char *str, int c) - locates the last ocurrence of c.

  • size_t ft_strlcat(char *dst, const char *src, size_t dstsize) - appends at most dstsize - strlen(dst) of src to dst.

  • size_t ft_strlcpy(char *dest, const char *src, size_t size) - copies up to size - 1 characters from src to dst and nul-terminates.

  • size_t ft_strlen(const char *str) - gives legth of string.

  • int ft_strncmp(const char *s1, const char *s2, size_t n) - compares the first n characters of both strings.

  • char *ft_strnstr(const char *str, const char *to_find, size_t len) - locates a substring in a string.

  • int ft_atoi(const char *str) - converts string to integer.

  • void *ft_calloc(size_t count, size_t size) - allocates count objects of size size.

  • char *ft_strdup(const char *s1) - duplicate string.

  • void ft_bzero(void *str, size_t n) - write zeroes to a byte string.

  • void *ft_memchr(const void *str, int c, size_t n) - locate byte in a byte string.

  • int ft_memcmp(const void *s1, const void *s2, size_t n) - compare byte string.

  • void *ft_memset(void *str, int c, size_t len) - fill a byte string with a byte value.

  • void *ft_memcpy(void *dst, const void *src, size_t len) - copy memory area. Overlapping is undefined.

  • void *ft_memmove(void *dst, const void *src, size_t len) - copies len bytes from src to dst. The strings may overlap.

Part 2 - Adittional functions.

  • char *ft_substr(char const *s, unsigned int start, size_t len) - creates a substring of size len from index start.
  • char *ft_strjoin(char const *s1, char const *s2) - concatenates s1 and s2 in a new string.
  • char *ft_strtrim(char const *s1, char const *set) - returns a copy of s1 with the characters specified in set removed from the beginning and the end.
  • char **ft_split(char const *s, char c) - returns an array of strings obtained by splitting s using c as a delimiter.
  • char *ft_itoa(int n) - converts integer to string.
  • char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) - creates a new string with the function f applied to the characters in s.
  • void ft_striteri(char *s, void (*f)(unsigned int, char*)) - applies the function f to each character in s.
  • void ft_putchar_fd(char c, int fd) - outputs c to given file descriptor.
  • void ft_putstr_fd(char *s, int fd) - outputs s to given file descriptor.
  • void ft_putnbr_fd(int n, int fd) - outputs n to given file descriptor.
  • void ft_putendl_fd(char *s, int fd) - outpurs s to given file descriptor and adds a newline.

Bonus functions.

  • t_list *ft_lstnew(void *content) - creates a new element.
  • void ft_lstadd_front(t_list **lst, t_list *new) - adds new at the beginning of the list.
  • int ft_lstsize(t_list *lst) - counts number of elements in the list.
  • t_list *ft_lstlast(t_list *lst) - returns the last element of the list.
  • void ft_lstadd_back(t_list **lst, t_list *new) - adds new at the end of the list.
  • void ft_lstdelone(t_list *lst, void (*del)(void*)) - frees the memory of the element's content.
  • void ft_lstclear(t_list **lst, void (*del)(void*)) - deletes and frees the given element and every successor.
  • void ft_lstiter(t_list *lst, void (*f)(void *)) - iterates lst and applies f to the content of each element.
  • t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) - creates a new list from the application of f to the content of each elements.

Third-party tests.

About

This project aims to code a C library regrouping usual functions to use in future projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published