libft
|
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | s_list |
A link in a multi-purpose linked list. More... | |
Typedefs | |
typedef struct s_list | t_list |
Functions | |
int | ft_abs (int a) |
Returns the absolute value of the argument. More... | |
int | ft_atoi (const char *str) |
Replicates behaviour of atoi from libc . More... | |
void | ft_bzero (void *s, size_t n) |
Replicates behaviour of bzero from libc . More... | |
void * | ft_calloc (size_t count, size_t size) |
Replicates behaviour of calloc from libc . More... | |
int | ft_isalnum (int c) |
Replicates behaviour of isalnum from libc . More... | |
int | ft_isalpha (int c) |
Replicates behaviour of isalpha from libc . More... | |
int | ft_isascii (int c) |
Replicates behaviour of isascii from libc . More... | |
int | ft_isdigit (int c) |
Replicates behaviour of isdigit from libc . More... | |
int | ft_isprint (int c) |
Replicates behaviour of isprint from libc . More... | |
int | ft_isspace (int c) |
Replicates behaviour of isspace from libc . More... | |
char * | ft_itoa (int n) |
Replicates behaviour of itoa from libc More... | |
void | ft_lstadd (t_list **alst, t_list *new) |
Adds an element at the beginning of a list. More... | |
void | ft_lstappend (t_list **alst, t_list *new) |
Adds the element new at the end of the list. More... | |
void | ft_lstdel (t_list **alst, void(*del)(void *, size_t)) |
Deletes all links in a list. More... | |
void | ft_lstdelone (t_list **alst, void(*del)(void *, size_t)) |
Deletes one link of a list. More... | |
void | ft_lstiter (t_list *lst, void(*f)(t_list *elem)) |
Applies a function to each member of a list. More... | |
t_list * | ft_lstlast (t_list *head) |
Returns the last element of a list. More... | |
t_list * | ft_lstmap (t_list *lst, t_list *(*f)(t_list *elem)) |
t_list * | ft_lstnew (void const *content, size_t content_size) |
Allocates a new list. More... | |
int | ft_max (int a, int b) |
Returns the maximum of two integer arguments. More... | |
void * | ft_memalloc (size_t size) |
Allocates memory of a given size and initializes it to 0. More... | |
void * | ft_memccpy (void *dst, const void *src, int c, size_t n) |
Replicates behaviour of memcpy from libc . More... | |
void * | ft_memchr (const void *s, int c, size_t n) |
Replicates behaviour of memchr from libc . More... | |
int | ft_memcmp (const void *s1, const void *s2, size_t n) |
Replicates behaviour of memcmp from libc . More... | |
void * | ft_memcpy (void *dst, const void *src, size_t n) |
Replicates behaviour of memcpy from libc . More... | |
void | ft_memdel (void **ap) |
Frees memory where a pointer points to and sets the pointer to NULL . More... | |
void * | ft_memmove (void *dst, const void *src, size_t n) |
Replicates behaviour of memmove from libc . More... | |
void * | ft_memset (void *b, int c, size_t len) |
Replicates behaviour of memset from libc . More... | |
int | ft_min (int a, int b) |
Returns the minimum of two integer arguments. More... | |
int | ft_power (int num, unsigned int exponent) |
Raises a number to a given power. More... | |
void | ft_putchar (char c) |
Writes a character to the standard output. More... | |
void | ft_putchar_fd (char c, int fd) |
Writes a character to a file descriptor. More... | |
void | ft_putendl (char const *s) |
Writes a string to the standard output followed by a newline. More... | |
void | ft_putendl_fd (char const *s, int fd) |
Writes a string to a file descriptor followed by a newline. More... | |
void | ft_putnbr (int n) |
Writes an integer to the standard output. More... | |
void | ft_putnbr_fd (int n, int fd) |
Writes an integer to a file descriptor. More... | |
void | ft_putnstr (char *s, size_t n) |
Writes the first n characters of a to the standard output. More... | |
void | ft_putnstr_fd (char *s, size_t n, int fd) |
Writes the first n characters of a string to a file descriptor. More... | |
int | ft_puts (char const *s) |
Replicates behaviour of puts from libc . More... | |
void | ft_putstr (char const *s) |
Writes a string to the standard output. More... | |
void | ft_putstr_fd (char const *s, int fd) |
Writes a string to a file descriptor. More... | |
int | ft_sqrt (int num) |
Computes an integer square root of a given number, if it exists. More... | |
char * | ft_strcapitalize (const char *str) |
Capitalizes all words in a string. More... | |
char * | ft_strcat (char *s1, const char *s2) |
Replicates behaviour of strcat from libc . More... | |
int | ft_strcchr (char const *str, char c) |
Counts the number of occurrences of a character in a string. More... | |
char * | ft_strchr (const char *s, int c) |
Replicates behaviour of strchr from libc . More... | |
void | ft_strclr (char *s) |
Sets each character of a string to 0. More... | |
int | ft_strcmp (const char *s1, const char *s2) |
Replicates strcmp from libc . More... | |
char * | ft_strcpy (char *dst, const char *src) |
Replicates behaviour of strcpy from libc . More... | |
void | ft_strdel (char **as) |
Frees a string and sets its pointer to NULL More... | |
char * | ft_strdup (const char *s1) |
Replicates behaviour of strdup from libc . More... | |
int | ft_strequ (const char *s1, const char *s2) |
Checks that two strings are identical. More... | |
int | ft_strintab (const char *str, char *const tab[]) |
Checks if a string is in a tab. More... | |
void | ft_striter (char *s, void(*f)(char *)) |
Applies a function to characters of a string. More... | |
void | ft_striteri (char *s, void(*f)(unsigned int, char *)) |
Applies a function to characters of a string and their indices. More... | |
char * | ft_strjoin (const char *s1, const char *s2) |
Joins two strings. More... | |
char | ft_strlast (char const *str) |
Returns the last characters (other than NULL -termination) of a string. More... | |
size_t | ft_strlcat (char *dst, const char *src, size_t dstsize) |
Replicates behaviour of strlcat from libc . More... | |
size_t | ft_strlcpy (char *dst, const char *src, size_t maxlen) |
Replicates behaviour of strlcpy from libc . More... | |
size_t | ft_strlen (const char *s) |
Replicates behaviour of strlen from libc . More... | |
char * | ft_strmap (char const *s, char(*f)(char)) |
Maps a function to characters of a string. More... | |
char * | ft_strmapi (char const *s, char(*f)(unsigned int, char)) |
Maps a function to characters of a string and their indices Applies the function f to each character of the string passed as argument by giving its index as first argument to create a “fresh” new string (with malloc ) resulting from the successive applications of f . More... | |
char * | ft_strncat (char *s1, const char *s2, size_t n) |
Replicates behaviour of strncat from libc . More... | |
int | ft_strncmp (const char *s1, const char *s2, size_t n) |
Replicates behaviour of strncmp from libc . More... | |
char * | ft_strncpy (char *dst, const char *src, size_t len) |
Replicates behaviour of strncpy from libc . More... | |
char * | ft_strndup (const char *s1, size_t len) |
Makes a new string and copies up to len characters to it. More... | |
int | ft_strnequ (char const *s1, char const *s2, size_t n) |
Checks that two strings are unequal. More... | |
char * | ft_strnew (size_t size) |
Allocates a fresh string. More... | |
char * | ft_strnstr (const char *haystack, const char *needle, size_t len) |
Replicates behaviour of strnstr from libc . More... | |
char * | ft_strrchr (const char *s, int c) |
Replicates behaviour of strrchr from libc . More... | |
char * | ft_strrev (const char *s) |
Reverses a string. More... | |
char ** | ft_strsplit (char const *str, char delim) |
Splits a string on whitespace characters. More... | |
char * | ft_strstr (const char *haystack, const char *needle) |
Replicates behaviour of strstr from libc . More... | |
char * | ft_strsub (char const *s, unsigned int start, size_t len) |
Copies a substring from a string. More... | |
char * | ft_strtrim (char const *s) |
Trims whitespace from the start and end of a string. More... | |
int | ft_tolower (int c) |
Replicates behaviour of tolower from libc . More... | |
int | ft_toupper (int c) |
Replicates behaviour of toupper from libc . More... | |
int ft_abs | ( | int | a | ) |
int ft_atoi | ( | const char * | str | ) |
void ft_bzero | ( | void * | s, |
size_t | n | ||
) |
Replicates behaviour of bzero
from libc
.
Definition at line 20 of file ft_bzero.c.
void* ft_calloc | ( | size_t | count, |
size_t | size | ||
) |
Replicates behaviour of calloc
from libc
.
Definition at line 21 of file ft_calloc.c.
int ft_isalnum | ( | int | c | ) |
Replicates behaviour of isalnum
from libc
.
Definition at line 20 of file ft_isalnum.c.
int ft_isalpha | ( | int | c | ) |
Replicates behaviour of isalpha
from libc
.
Definition at line 20 of file ft_isalpha.c.
int ft_isascii | ( | int | c | ) |
Replicates behaviour of isascii
from libc
.
Definition at line 20 of file ft_isascii.c.
int ft_isdigit | ( | int | c | ) |
Replicates behaviour of isdigit
from libc
.
Definition at line 20 of file ft_isdigit.c.
int ft_isprint | ( | int | c | ) |
Replicates behaviour of isprint
from libc
.
Definition at line 20 of file ft_isprint.c.
int ft_isspace | ( | int | c | ) |
Replicates behaviour of isspace
from libc
.
Definition at line 20 of file ft_isspace.c.
char* ft_itoa | ( | int | n | ) |
Adds an element at the beginning of a list.
alst | The pointer to the first link of a list |
new | The link to add at the beginning of the list |
Definition at line 22 of file ft_lstadd.c.
Adds the element new at the end of the list.
alst | The pointer to the first link in a list |
new | The link to add at the beginning of the list |
Definition at line 22 of file ft_lstappend.c.
void ft_lstdel | ( | t_list ** | alst, |
void(*)(void *, size_t) | del | ||
) |
Deletes all links in a list.
Takes as a parameter the address of a pointer to a link and frees the memory of this link and every successors of that link using the functions del
and free
. Finally the pointer to the link that was just freed must be set to NULL
(quite similar to the function memdel
).
alst | The address of a pointer to the first link of a list that needs to be freed. |
del | The address of a function to apply to each link of a list. |
Definition at line 29 of file ft_lstdel.c.
void ft_lstdelone | ( | t_list ** | alst, |
void(*)(void *, size_t) | del | ||
) |
Deletes one link of a list.
Takes as a parameter a link’s pointer address and frees the memory of the link’s content using the function del
given as a parameter, then frees the link’s memory using free
. The memory of next must not be freed under any circumstance. Finally, the pointer to the link that was just freed must be set to NULL
(quite similar to the function memdel
).
alst | The adress of a pointer to a link that needs to be freed. |
del | The address of a function to apply to each link of a list. |
Definition at line 29 of file ft_lstdelone.c.
Applies a function to each member of a list.
lst | A pointer to the first link of a list. |
f | The address of a function to apply to each link of a list. |
Definition at line 22 of file ft_lstiter.c.
Returns the last element of a list.
lst | A pointer’s to the first link of a list. |
Definition at line 22 of file ft_lstlast.c.
Maps a function to each member of a list
lst | A pointer’s to the first link of a list. |
f | The address of a function to apply to each link of a list. |
NULL
if allocaton fails. Definition at line 23 of file ft_lstmap.c.
t_list* ft_lstnew | ( | void const * | content, |
size_t | content_size | ||
) |
Allocates a new list.
Allocates (with malloc
) and returns a “fresh” link. The variables content and content_size of the new link are initialized by copy of the parameters of the function. If the parameter content
is NULL
, the variable content
is initialized to NULL
and the variable content_size
is initialized to 0
even if the parameter content_size
isn’t. The variable next
is initialized to NULL
.
content | The content to put in the new link. |
content_size | The size of the content of the new link. |
NULL
if allocation fails. Definition at line 31 of file ft_lstnew.c.
int ft_max | ( | int | a, |
int | b | ||
) |
Returns the maximum of two integer arguments.
[in] | a | The first integer to compare. |
[in] | b | The second integer to compare. |
void* ft_memalloc | ( | size_t | size | ) |
Allocates memory of a given size and initializes it to 0.
size | The size of the memory that needs to be allocated. |
NULL
if allocation fails. Definition at line 24 of file ft_memalloc.c.
void* ft_memccpy | ( | void * | dst, |
const void * | src, | ||
int | c, | ||
size_t | n | ||
) |
Replicates behaviour of memcpy
from libc
.
Definition at line 20 of file ft_memccpy.c.
void* ft_memchr | ( | const void * | s, |
int | c, | ||
size_t | n | ||
) |
Replicates behaviour of memchr
from libc
.
Definition at line 20 of file ft_memchr.c.
int ft_memcmp | ( | const void * | s1, |
const void * | s2, | ||
size_t | n | ||
) |
Replicates behaviour of memcmp
from libc
.
Definition at line 20 of file ft_memcmp.c.
void* ft_memcpy | ( | void * | dst, |
const void * | src, | ||
size_t | n | ||
) |
Replicates behaviour of memcpy
from libc
.
Definition at line 20 of file ft_memcpy.c.
void ft_memdel | ( | void ** | ap | ) |
Frees memory where a pointer points to and sets the pointer to NULL
.
ap | The pointer |
Definition at line 22 of file ft_memdel.c.
void* ft_memmove | ( | void * | dst, |
const void * | src, | ||
size_t | n | ||
) |
Replicates behaviour of memmove
from libc
.
Definition at line 20 of file ft_memmove.c.
void* ft_memset | ( | void * | b, |
int | c, | ||
size_t | len | ||
) |
Replicates behaviour of memset
from libc
.
Definition at line 20 of file ft_memset.c.
int ft_min | ( | int | a, |
int | b | ||
) |
Returns the minimum of two integer arguments.
[in] | a | The first integer to compare. |
[in] | b | The second integer to compare. |
int ft_power | ( | int | num, |
unsigned int | exponent | ||
) |
Raises a number to a given power.
num | The base. |
exponent | The exponent. |
0
if integer overflow occurred. Definition at line 24 of file ft_power.c.
void ft_putchar | ( | char | c | ) |
Writes a character to the standard output.
c | The character to output. |
Definition at line 22 of file ft_putchar.c.
void ft_putchar_fd | ( | char | c, |
int | fd | ||
) |
Writes a character to a file descriptor.
c | The character to output. |
fd | The file descriptor. |
Definition at line 23 of file ft_putchar_fd.c.
void ft_putendl | ( | char const * | s | ) |
Writes a string to the standard output followed by a newline.
s | The string to output. |
Definition at line 21 of file ft_putendl.c.
void ft_putendl_fd | ( | char const * | s, |
int | fd | ||
) |
Writes a string to a file descriptor followed by a newline.
s | The string to output. |
fd | The file descriptor. |
Definition at line 22 of file ft_putendl_fd.c.
void ft_putnbr | ( | int | n | ) |
Writes an integer to the standard output.
n | The integer to output. |
Definition at line 21 of file ft_putnbr.c.
void ft_putnbr_fd | ( | int | n, |
int | fd | ||
) |
Writes an integer to a file descriptor.
n | The integer to print. |
fd | The file descriptor. |
Definition at line 23 of file ft_putnbr_fd.c.
void ft_putnstr | ( | char * | s, |
size_t | n | ||
) |
Writes the first n characters of a to the standard output.
s | The string, the characters of which to output. |
n | The number of characters to output. |
s
contains less than n
characters, behaviour is undefined. Definition at line 24 of file ft_putnstr.c.
void ft_putnstr_fd | ( | char * | s, |
size_t | n, | ||
int | fd | ||
) |
Writes the first n characters of a string to a file descriptor.
s | The string, the characters of which to output. |
n | The number of characters to output. |
fd | The file descriptor. |
s
contains less than n
characters, behaviour is undefined. Definition at line 25 of file ft_putnstr_fd.c.
int ft_puts | ( | char const * | s | ) |
void ft_putstr | ( | char const * | s | ) |
Writes a string to the standard output.
s | The string to output. |
Definition at line 22 of file ft_putstr.c.
void ft_putstr_fd | ( | char const * | s, |
int | fd | ||
) |
Writes a string to a file descriptor.
s | The string to output. |
fd | The file descriptor. |
Definition at line 23 of file ft_putstr_fd.c.
int ft_sqrt | ( | int | num | ) |
char* ft_strcapitalize | ( | const char * | s1 | ) |
Capitalizes all words in a string.
Capitalizes all words (defined as stretches of alpha-numeric characters) in a NULL
-terminated string and writes them to a newly allocated string.
ft_strcapitalize("My word IS 42about%8THEM")
returns "My Word Is 42about%8them")
s1 | The string to capitalize. |
str
in which all words have been capitalized, or NULL
if allocation fails. Definition at line 51 of file ft_strcapitalize.c.
char* ft_strcat | ( | char * | s1, |
const char * | s2 | ||
) |
Replicates behaviour of strcat
from libc
.
Definition at line 20 of file ft_strcat.c.
int ft_strcchr | ( | char const * | str, |
char | c | ||
) |
Counts the number of occurrences of a character in a string.
str | The string in which to search. |
c | The character for which to search. |
Definition at line 23 of file ft_strcchr.c.
char* ft_strchr | ( | const char * | s, |
int | c | ||
) |
Replicates behaviour of strchr
from libc
.
Definition at line 20 of file ft_strchr.c.
void ft_strclr | ( | char * | s | ) |
Sets each character of a string to 0.
s | The string that needs to be cleared. |
Definition at line 21 of file ft_strclr.c.
int ft_strcmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Replicates strcmp
from libc
.
Definition at line 20 of file ft_strcmp.c.
char* ft_strcpy | ( | char * | dst, |
const char * | src | ||
) |
Replicates behaviour of strcpy
from libc
.
Definition at line 20 of file ft_strcpy.c.
void ft_strdel | ( | char ** | as | ) |
Frees a string and sets its pointer to NULL
Takes as a parameter the address of a string that need to be freed with free
, then sets its pointer to NULL
.
as | The string’s address that needs to be freed and its pointer set to NULL . |
Definition at line 24 of file ft_strdel.c.
char* ft_strdup | ( | const char * | s1 | ) |
Replicates behaviour of strdup
from libc
.
Definition at line 20 of file ft_strdup.c.
int ft_strequ | ( | const char * | s1, |
const char * | s2 | ||
) |
Checks that two strings are identical.
Performs lexicographical comparison between s1
and s2
.
s1 | The first string to be compared. |
s2 | The second string to be compared. |
1
if the strings are identical or 0
otherwise. Definition at line 24 of file ft_strequ.c.
int ft_strintab | ( | const char * | str, |
char *const | tab[] | ||
) |
Checks if a string is in a tab.
Performs lexicographical comparison between a given string and strings contained in a NULL
-terminated tab.
str | The string to search for. |
tab | The NULL -terminated tab to search in. |
1
if the tab contains the string or 0
otherwise. Definition at line 26 of file ft_strintab.c.
void ft_striter | ( | char * | s, |
void(*)(char *) | f | ||
) |
Applies a function to characters of a string.
Applies the function f
to each character of the string passed as argument. Each character is passed by address to f
to be modified if necessary.
s | The string to iterate. |
f | The function to apply to each character of s . |
Definition at line 25 of file ft_striter.c.
void ft_striteri | ( | char * | s, |
void(*)(unsigned int, char *) | f | ||
) |
Applies a function to characters of a string and their indices.
Applies the function f
to each character of the string passed as argument, and passing its index as first argument. Each character is passed by address to f
to be modified if necessary.
s | The string to iterate. |
f | The function to apply to each character of s and its index. |
Definition at line 25 of file ft_striteri.c.
char* ft_strjoin | ( | const char * | s1, |
const char * | s2 | ||
) |
Joins two strings.
Allocates (with malloc
) and returns a “fresh” string ending with '\0'
, result of the concatenation of s1
and s2
. If the allocation fails the function returns NULL
.
s1 | The prefix string. |
s2 | The suffix string. |
Definition at line 26 of file ft_strjoin.c.
char ft_strlast | ( | char const * | str | ) |
Returns the last characters (other than NULL
-termination) of a string.
str | The string. |
0
if it is empty. Definition at line 22 of file ft_strlast.c.
size_t ft_strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize | ||
) |
Replicates behaviour of strlcat
from libc
.
Definition at line 20 of file ft_strlcat.c.
size_t ft_strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | maxlen | ||
) |
Replicates behaviour of strlcpy
from libc
.
Definition at line 20 of file ft_strlcpy.c.
size_t ft_strlen | ( | const char * | s | ) |
Replicates behaviour of strlen
from libc
.
Definition at line 20 of file ft_strlen.c.
char* ft_strmap | ( | char const * | s, |
char(*)(char) | f | ||
) |
Maps a function to characters of a string.
Applies the function f
to each character of the string given as argument to create a “fresh” new string (with malloc
) resulting from the successive applications of f
.
s | The string to map. |
f | The function to apply to each character of s . |
f
, or NULL
if allocation fails. Definition at line 27 of file ft_strmap.c.
char* ft_strmapi | ( | char const * | s, |
char(*)(unsigned int, char) | f | ||
) |
Maps a function to characters of a string and their indices Applies the function f
to each character of the string passed as argument by giving its index as first argument to create a “fresh” new string (with malloc
) resulting from the successive applications of f
.
s | The string to map. |
f | The function to apply to each character and its index of s . |
NULL
if allocation fails. Definition at line 28 of file ft_strmapi.c.
char* ft_strncat | ( | char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Replicates behaviour of strncat
from libc
.
Definition at line 20 of file ft_strncat.c.
int ft_strncmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Replicates behaviour of strncmp
from libc
.
Definition at line 20 of file ft_strncmp.c.
char* ft_strncpy | ( | char * | dst, |
const char * | src, | ||
size_t | len | ||
) |
Replicates behaviour of strncpy
from libc
.
Definition at line 20 of file ft_strncpy.c.
char* ft_strndup | ( | const char * | s1, |
size_t | len | ||
) |
Makes a new string and copies up to len
characters to it.
Allocate sufficient memory for a string of len
characters, do the copy of len
characters, NULL
terminate the string, and return a pointer to it. The pointer may subsequently be used as an argument to the function free
.
s1 | String to be copied from. |
len | Number of characters to copy. |
len
with copied characters or NULL
if allocation failed. s1
contains less than len
characters, behaviour is undefined. Definition at line 30 of file ft_strndup.c.
int ft_strnequ | ( | char const * | s1, |
char const * | s2, | ||
size_t | n | ||
) |
Checks that two strings are unequal.
Lexicographical comparison between s1
and s2
up ton
characters or until a '\0'
is reached.
s1 | The first string to be compared. |
s2 | The second string to be compared. |
n | The maximum number of characters to be compared. |
1
or 0
according to if the 2 strings are identical or not. Definition at line 26 of file ft_strnequ.c.
char* ft_strnew | ( | size_t | size | ) |
Allocates a fresh string.
Allocates (with malloc
) and returns a “fresh” string ending with '\0'
. Each character of the string is initialized at '\0'
.
size | The size of the string to be allocated. |
0
or NULL
if allocation failed. Definition at line 25 of file ft_strnew.c.
char* ft_strnstr | ( | const char * | haystack, |
const char * | needle, | ||
size_t | len | ||
) |
Replicates behaviour of strnstr
from libc
.
Definition at line 20 of file ft_strnstr.c.
char* ft_strrchr | ( | const char * | s, |
int | c | ||
) |
Replicates behaviour of strrchr
from libc
.
Definition at line 20 of file ft_strrchr.c.
char* ft_strrev | ( | const char * | s | ) |
Reverses a string.
Allocates (with malloc
) and returns a “reversed” NULL
-terminated string.
ft_strrev("0123456789")
returns "9876543210"
s | String to be reversed. |
NULL
if allocation failed. Definition at line 26 of file ft_strrev.c.
char** ft_strsplit | ( | char const * | s, |
char | delim | ||
) |
Splits a string on whitespace characters.
Allocates (with malloc
) and returns an array of “fresh” strings (all ending with '\0'
, including the array itself) obtained by splitting s
using the character c
as a delimiter.
ft_strsplit("*hello*fellow***students*", ’*’)
returns the array ["hello", "fellow", "students"]
. s | The string to split. |
delim | The delimiter character. |
NULL
if any of the allocations failed. Definition at line 70 of file ft_strsplit.c.
char* ft_strstr | ( | const char * | haystack, |
const char * | needle | ||
) |
Replicates behaviour of strstr
from libc
.
Definition at line 20 of file ft_strstr.c.
char* ft_strsub | ( | char const * | s, |
unsigned int | start, | ||
size_t | len | ||
) |
Copies a substring from a string.
Allocates (with malloc
) and returns a “fresh” substring from the string given as argument. The substring begins at index start
and is of size len
. If start
and len
aren’t refering to a valid substring, the behavior is undefined.
s | The string from which create the substring. |
start | The start index of the substring. |
len | The size of the substring. |
NULL
if allocation failed. Definition at line 28 of file ft_strsub.c.
char* ft_strtrim | ( | char const * | s | ) |
Trims whitespace from the start and end of a string.
Allocates (with malloc
) and returns a copy of the string given as argument without whitespaces at the beginning or at the end of the string. Will be considered as whitespaces the following characters ' '
, '\n'
and '\t'
. If s
has no whitespaces at the beginning or at the end, the function returns a copy of s
.
s | The string to be trimmed. |
s
or NULL
if allocation failed. Definition at line 34 of file ft_strtrim.c.
int ft_tolower | ( | int | c | ) |
Replicates behaviour of tolower
from libc
.
Definition at line 20 of file ft_tolower.c.
int ft_toupper | ( | int | c | ) |
Replicates behaviour of toupper
from libc
.
Definition at line 20 of file ft_toupper.c.