-
Notifications
You must be signed in to change notification settings - Fork 23
Personal Functions Documentation
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.
- ft_capitalize
- ft_countwords
- ft_islower
- ft_isupper
- ft_strndup
- ft_lst_reverse
- ft_realloc
- ft_strjoinch
- ft_strnchr
- ft_copyuntil
- ft_strstartswith
- ft_intlen
- ft_strendswith
- ft_pathjoin
- ft_lstaddback
- get_next_line
- ft_putnstr
- ft_strreplace
- ft_isemptystr
- ft_strsplitall
- ft_countwordsall
- ft_freestrarr
- ft_strjoincl
- ft_strjoinchcl
- ft_count2darray
- ft_strarrmax
- ft_get_parent_path
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 |
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 |
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 |
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 |
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 |
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 |
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 *
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 |
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 |
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 |
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 |
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) |
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 |
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
|
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 |
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. |
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 |
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
|
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 |
char **ft_strsplitall(char const *s)
Same as ft_strsplit but splits by most space characters: ' ', \t, \r, \f.
int ft_countwordsall(char const *str);
Same as ft_countwords but uses most space characters as delimiters: ' ', \t, \r, \f.
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 |
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. |
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. |
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
|
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
|
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. |