Skip to content

Personal Functions Documentation

Nick Rameau edited this page Jul 20, 2017 · 5 revisions

Welcome to the Libft wiki

This wiki is here to document all my personal functions. If you actually want documentation for the other functions, please, refer to the project instructions.

TOC

ft_capitalize

char *ft_capitalize(char *s)

Description Param. #1 Return Value
Capitalizes the first letter of every word in a string The string to capitalize The new string with capitalized words

ft_countwords

int ft_countwords(char const *str, char c)

Description Param. #1 Param. #2 Return Value
Counts the amount of words separated by a specific delimiter in a string The string in which to operate The delimiter The amount of words found

ft_islower

int ft_islower(int c)

Description Param. #1 Return Value
Tests for a lowercase character The character to test 0 if the character tests false and 1 if the character tests true

ft_isupper

int ft_isupper(int c)

Description Param. #1 Return Value
Tests for an uppercase character The character to test 0 if the character tests false and 1 if the character tests true

ft_strndup

char *ft_strndup(const char *s1, size_t n)

Description Param. #1 Param. #2 Return Value
Allocates a specific amount of memory to copy a string The string on which to operate The maximum amount of characters to copy from the string A pointer to the new string

ft_lst_reverse

t_list *ft_lst_reverse(t_list *alst)

Description Param. #1 Return Value
Reverses a linked list The list on which to operate The new, reversed list

ft_realloc

void *ft_realloc(void *ptr, size_t prev_size, size_t new_size)

Description | Param. #1 | Param. #2 | Param. #3 | Return Value :-----------: | :-----------: | :-----------: | :-----------: Allocates a new amount of memory for a string | The string on which to operate | The previous size of the string | The maximum amount of memory to allocate | The new string to be casted as char *

ft_strjoinch

char *ft_strjoinch(char const *s1, char c)

Description Param. #1 Param. #2 Return Value
Allocates enough memory to concatenate a string and a character The string on which to operate The character to append The new string

ft_strnchr

char *ft_strnchr(char *s, char c, int offset)

Description Param. #1 Param. #2 Param. #3 Return Value
Locates the first occurrence of a character in a string The string on which to operate The character to find A number by witch to offset the returned pointer A pointer to the located character + the offset. Or NULL if the character does not appear in the string

ft_copyuntil

int ft_copyuntil(char **dst, char *src, char c)

Description Param. #1 Param. #2 Param. #3 Return Value
Copies from one string to another one until it finds a specific character The address of the destination string The source string The character to stop at The position at which it found the character

ft_strstartswith

int ft_strstartswith(char *s1, char *s2)

Description Param. #1 Param. #2 Return Value
Checks if s1 starts with s2 The string to search in The string to search for 1 if s1 starts with s2, 0 if not

ft_intlen

int ft_intlen(int num)

Description Param. #1 Return Value
Calculates the length num The target integer An integer between 1 and 10 (Maximum possible length of an int)

ft_strendswith

int ft_strendswith(char *s1, char *s2)

Description Param. #1 Param. #2 Return Value
Checks if s1 ends with s2 The string to search in The string to search for 1 if s1 ends with s2, 0 if not

ft_pathjoin

char *ft_pathjoin(char *p1, char *p2)

Description Param. #1 Param. #2 Return Value
Appends the path s2 to the path s1 by making sure s1 didn't already have a '/' at the end The path to append to The path to append The resulting path from joining s2 to s1

ft_lstaddback

void ft_lstaddback(t_list **alst, t_list *new)

Description Param. #1 Param. #2 Return Value
Adds the list new at the end of the list alst The address of the list to add to The list to add N/A

get_next_line

int get_next_line(const int fd, char **line)

Description Param. #1 Param. #2 Return Value
Reads the file descriptor of a file line by line until the end of file The file descriptor to read from The line read from the file or NULL if EOF reached -1, 0, 1 depending on wether an error has occurred, the reading has been completed or a line has been read respectively. For more info, refer to the specific repo.

ft_putnstr

void ft_putnstr(char *str, int n)

Description Param. #1 Param. #2 Return Value
Prints a string on the screen up until n characters The string to print The maximum amount of characters to print N/A

ft_strreplace

char *ft_strreplace(char *str, char *term, char *replace_by)

Description Param. #1 Param. #2 Param. #3 Return Value
Replaces a sub string from a string by another string The string to work on The term to replace The string to replace the term by The resulting string or NULL if term does not exist in str

ft_isemptystr

int ft_isemptystr(char *str, int consider_space)

Description Param. #1 Param. #2 Return Value
Checks whether a string is empty or not The string to work on A boolean to know if we should consider a string filled with spaces as an empty string 1 if the string is empty, 0 if not

ft_strsplitall

char **ft_strsplitall(char const *s)

Same as ft_strsplit but splits by most space characters: ' ', \t, \r, \f.

ft_countwordsall

int ft_countwordsall(char const *str);

Same as ft_countwords but uses most space characters as delimiters: ' ', \t, \r, \f.

ft_freestrarr

void ft_freestrarr(char **arr)

Description Param. #1 Return Value
Frees an array of strings or 2d array The 2d array to free N/A

ft_strjoincl

char *ft_strjoincl(char *s1, char *s2, int free_both)

Description Param. #1 Param. #2 Param. #3 Return Value
Joins two strings together and frees the first passed string, also frees the second one depending on free_both The first string to join The second string to join A boolean to know if we should free both of the strings or only one The resulting string or NULL on error.

ft_strjoinchcl

char *ft_strjoinchcl(char *s1, char c)

Description Param. #1 Param. #2 Return Value
Joins a string and a character together and frees the string The string to join The character to join The resulting string or NULL on error.

ft_count2darray

int ft_count2darray(char **arr)

Description Param. #1 Return Value
Counts the elements of a 2d array The 2d array to iterate on The total amount of elements in arr

ft_strarrmax

int ft_strarrmax(char **arr)

Description Param. #1 Return Value
Finds the length of the longest element of a 2d array The 2d array to iterate on The length of the longest element of arr

ft_get_parent_path

char *ft_get_parent_path(char *path)

Description Param. #1 Return Value
Returns the parent path from a given path The path to find the parent of The parent path of path, which can/should be freed later.