Skip to content

Latest commit

 

History

History
50 lines (44 loc) · 6.02 KB

README.md

File metadata and controls

50 lines (44 loc) · 6.02 KB

Libft

About the project 💡

Building my own basic C static library, which will be used throughout the rest of the program (42 Cursus). The ft_* functions mostly mimic the behaviour of the traditional C functions, and must be written using at most write() and malloc().

  • Part 1 - re-code a set of the libc functions, as defined in their man
  • Part 2 - code functions not included in the libc

Part 1 - Libc functions

Function Description
ft_isalpha Checks whether a character is an alphabet or not.
ft_isdigit Check if the passed character is a digit or not (0 through 9).
ft_isalnum Checks for an alphanumeric character; it is equivalent to (isalpha(c) || isdigit(c)).
ft_isascii Checks whether c is a 7-bit unsigned char value that fits into the ASCII character set.
ft_isprint Checks for any printable character including space.
ft_strlen Calculates the length of the string pointed to by s, excluding the terminating null byte.
ft_memset Fills the first n bytes of the memory area pointed to by s with the constant byte c.
ft_bzero Set n bytes of *s to 0.
ft_memcpy Copies n bytes from memory area src to memory area dst. The memory areas must not overlap. Use ft_memmove if the memory areas do overlap.
ft_memmove Copies n bytes from memory area src to memory area dest. The memory area may overlap. The copy is always done in a non-destructive manner.
ft_strlcpy Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result.
ft_strlcat Appends the NUL-terminated string src to the end of dst. It will append at most size - strlen(dst) - 1 bytes, NUL-terminating the result.
ft_toupper Convert a lowercase letter to uppercase.
ft_tolower Convert a uppercase letter to lowercase.
ft_strchr Locate character in string and returns a pointer to the first occurrence.
ft_strrchr Locate character in string and returns a pointer to the last occurrence.
ft_strncmp Compares the two strings s1 and s2, only the first (at most) n bytes of them.
ft_memchr Scans the initial n bytes of the memory area pointed by s for the first instance of c.
ft_memcmp Compares the first n bytes of the memory areas s1 and s2.
ft_strnstr Locate the first occurrence of the null-terminated substring in the bigstring, where not more than len characters are searched.
ft_atoi Converts the initial portion of the string pointed to by str to int.
ft_calloc Allocate and free dynamic memory, setting the memory to zero.
ft_strdup Allocated and returns a duplication of the str.

Part 2 - Additional functions

Function Description
ft_substr Allocates and returns a substring from the string s.
ft_strjoin Allocates and returns a new string, which is the result of the concatenation of 's1' and 's2'.
ft_strtrim Allocates and returns a copy of 's1' with the characters specified in 'set' removed from the beginning and the end of the string.
ft_split Allocates and returns an array of strings obtwained by splitting 's' using the character 'c' as a delimiter.
ft_itoa Allocates and returns a string representing the integer received as an argument.
ft_strmapi Applies the function 'f' to each character of the string 's' to create a new string resulting from successive applications of 'f'.
ft_putchar_fd Outputs the character 'c' to the given file descriptor.
ft_putstr_fd Outputs the string 's' to the given file descriptor.
ft_putendl_fd Outputs the string 's' to the given file descriptor, followed by a newline.
ft_putnbr_fd Outputs the integer 'n' to the given file descriptor.