Coder Social home page Coder Social logo

libft's Introduction

libft

N|Solid

TOC

Building

$> git clone https://github.com/pantos05/libft.git
$> cd libft
$> make

What is libft?

Libft is an individual project at 21 that requieres us to re-create some standard C library functions for future projects, and have a deeper understanding of data structures and basic algorithms. At 21 we are not allowed to use some standard libraries on our projects, so we have to keep growing this libary with our own functions as we go farther in the program.

What's in it?

There are 2 sections: Libc Functions: Some of the standard C functions Additional functions: Functions that will be useful for later projects

List of functions

Libc functions Additional functions
ft_memset ft_substr
ft_bzero ft_strjoin
ft_memcpy ft_strtrim
ft_memmove ft_split
ft_memchr ft_itoa
ft_memcmp ft_strmapi
ft_strlen ft_putchar_fd
ft_strdup ft_putstr_fd
ft_strcpy ft_putendl_fd
ft_strlcpy ft_putnbr_fd
ft_strcat
ft_strlcat
ft_strchr
ft_strrchr
ft_strstr
ft_strnstr
ft_strcmp
ft_strncmp
ft_atoi
ft_isalpha
ft_isdigit
ft_isalnum
ft_isascii
ft_isprint
ft_toupper
ft_tolower
ft_calloc
ft_memset
void *ft_memset(void *s, int c, size_t len)
Description Param. #1 Param. #2 Param. #3 Return Value
Fill with "len" bytes of "c" the memory of "s" The string on which to operate Value c (converted to an unsigned char) The number of bytes A pointer to the memory area s
void *ft_bzero(void *s, size_t n)
Description Param. #1 Param. #2 Return Value
Erases the data in the "n" bytes of the memory starting at the location pointed by "s" writing zeroes The string on which to operate The number of bytes None
void *ft_memcpy(void *dst, const void *src, size_t n)
Description Param. #1 Param. #2 Param. #3 Return Value
Copies n bytes from memory area src to memory of dst. The memory areas must not overlap. Use ft_memmove if the memory areas do overlap. Memory area dst Memory area src The number of bytes A pointer to the memory area dst
void *ft_memmove(void *dst, const void *src, size_t len)
Description Param. #1 Param. #2 Param. #3 Return Value
Copies len bytes from the memory of src to dst. Memories may overlap. First, the bytes in src are copied into a temporary array and then to dst. Memory area dst Memory ares arc The number of bytes A pointer to the memory area dst
void *ft_memchr(const void *s, int c, size_t n)
Description Param. #1 Param. #2 Param. #3 Return Value
Scans the initial n bytes of s for the first instance of c Memory area s A character to search The number of bytes A pointer to the matching byte or NULL if the character does not occur in the given memory area
void *ft_memcmp(void *dst, const void *src, size_t n)
Description Param. #1 Param. #2 Param. #3 Return Value
Compares byte string s1 against byte string s2 Memory area s1 Memory area s2 The number of bytes < 0 if s1 is less than s2, > 0 if s1 is graeter than s2, = 0 if s1 is equal to s2
size_t ft_strlen(const char *s)
Description Param. #1 Return Values
Calculates the length of the string pointed to by s, excluding the terminating null byte ('\0') The string to calculate Number of characters in the string pointed to by s
char *ft_strdup(const char *s))
Description Param. #1 Return Values
Duplicate string s1. Memory for the new string is obtained with malloc, and can be freed with free The string to duplicate A pointer to the duplicated string. NULL if insufficient memory was available
char *ft_strndup(const char *s, size_t n)
Description Param. #1 Param. #2 Return Value
Allocates a specific amount of memory to copy a string The string to copy The maximum amount of characters to copy from the string A pointer to the new string
char *ft_strchr(const char *s, int c)
Description Param. #1 Param. #2 Return Value
Locates the first occurrence of 'c' in the string pointed to by 's'. The terminating null character is considered to be part of the string, therefore if 'c' is '\0', locates the terminating '\0' Pointer to string Character to be located A pointer to the first occurrence of the character c in the string or NULL if the character is not found
char *ft_strrchr(const char *s, int c)
Description Param. #1 Param. #2 Return Value
Locates the last occurrence of 'c' in the string pointed to by 's'. The terminating null character is considered to be part of the string, therefore if 'c' is '\0', locates the terminating '\0' Pointer to string Character to be located A pointer to the last occurrence of the character c in the string or NULL if the character is not found
char *ft_strcpy(char *dst, const char *src)
Description Param. #1 Param. #2 Return Value
Copy a string, including the terminating null byte ('\0') Destination array String to be copied A pointer to the destination string dst
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
Description Param. #1 Param. #2 Param. #3 Return Value
Copies up to dstsize - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result Destination array String to be copied Number of characters to be copied from src Total length of the string to create (length of src)
char *ft_strcpy(char *dst, const char *src)
Description Param. #1 Param. #2 Return Value
Concatenate two strings (append s2 to s1), including the terminating null byte ('\0') Destination array String to be appended to dst A pointer to the resulting string dst
size_t ft_strlcat(char *dst, const char *src, size_t size)
Description Param. #1 Param. #2 Param. #3 Return Value
Concatenate the string src to the end of dst. It will concatenate at most size - strlen(dst) - 1 bytes, NUL-terminating the result Destination array String to be appended to dst Maximum number of characters to be appended The initial length of dst plus the length of src
char *ft_strnstr(const char *haystack, const char *needle, size_t len)
Description Param. #1 Param. #2 Param. #3 Return Value
Locate substring, where not more than 'len' characters are searched. Finds the first occurrence of the substring 'needle' in the string 'haystack'. The terminating null bytes ('\0') are not compared. String to be scanned The small string to be searched in 'haystack' string The maximum amount of characters to be searched A pointer to the first character of the first occurrence of little is returned. NULL if the substring is not found. If 'needle' is an empty string, 'haystack' is returned
int ft_atoi(const char *str)
Description Param. #1 Return Value
Convert a string to a integer The string to be converted to int The converted value
int ft_isalpha(int c)
Description Param. #1 Return Value
Check for a alpabetic character, it is equivalent to (ft_isupper(c) or ft_islower(c)) The character to test 0 if the character tests false and 1 if the character tests true
int ft_isdigit(int c)
Description Param. #1 Return Value
Check for a digit (0 through 9) The character to test 0 if the character tests false and 1 if the character tests true
int ft_isalnum(int c)
Description Param. #1 Return Value
Check for an alphanumeric character; it is equivalent to (ft_isalpha or ft_isdigit) The character to test 0 if the character tests false and 1 if the character tests true
int ft_isascii(int c)
Description Param. #1 Return Value
Checks for an ASCII character, which is any character between 0 and octal 0177 inclusive The character to test 0 if the character tests false and 1 if the character tests true
int ft_isprint(int c)
Description Param. #1 Return Value
Checks for any printable character including space The character to test 0 if the character tests false and 1 if the character tests true
int ft_toupper(int c)
Description Param. #1 Return Value
If the character passed as an argument is a lowercase, convert to upper The character to convert If c is a lowercase letter, returns its uppercase equivalent. Otherwise, it returns c.
int ft_tolower(int c)
Description Param. #1 Return Value
If the character passed as an argument is an uppercase, convert to lower The character to convert If c is a uppercase letter, returns its lowercase equivalent. Otherwise, it returns c.
void *ft_calloc(size_t count, size_t size)
Description Param. #1 Param. #2 Return Value
Allocates enough space for count objects that are size bytes of memory each, and returns a pointer to the allocated memory. The allocated memory is filled with bytes of value zero Number of elements to be allocated Size of elements A pointer to the allocated memory, or NULL if the request fails
char *ft_substr(char const *s, unsigned int start, size_t len)
Description Param. #1 Param. #2 Param. #3 Return Value
Allocates (with malloc) and returns a substring from the string given in argument. The substring begins at index 'start' and is of maximum size 'len' The string from which create the substring The start index of the substring in the string The maximum length of the substring The substring. NULL if the allocation fails
char *ft_strjoin(char const *s1, char const *s2)
Description Param. #1 Param. #2 Return Value
Allocates (with malloc) and returns a new string, result of the concatenation of s1 and s2 The prefix string The suffix string The new string. NULL if the allocation fails
char *ft_strtrim(char const *s1, char const *s2)
Description Param. #1 Param. #2 Return Value
Allocates (with malloc) and returns a copy of the string given as argument without the characters specified in the set argument at the beginning and the end of the string The string to be trimmed The reference set of character to trim The trimmed string. NULL if the allocation fails
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
Description Param. #1 Param. #2 Return Value
Applies the function f to each character of the string passed as argument to create a new string (with malloc) resulting from successive applications of f The string on which to iterate The function to apply to each character The string created from the successive applications of f. Returns NULL if the allocation fails

libft's People

Contributors

pantos05 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.