Libft
 
Loading...
Searching...
No Matches
String functions

String functions. More...

Functions

size_t ft_strlen (const char *the_string)
 Len of string without '\0'.
 
size_t ft_strlen_char (const char *the_string, int character)
 Number of occurrence of character in the string.
 
size_t ft_strlcpy (char *dst, const char *src, size_t size)
 
size_t ft_strlcat (char *dst, const char *src, size_t size)
 Concatenate src into dst, up to size bytes.
 
char * ft_strchr (const char *string, int searched_char)
 Find first occurrence of searched_char.
 
char * ft_strrchr (const char *string, int searched_char)
 Find last occurrence of searched_char.
 
int ft_strncmp (const char *first, const char *second, size_t length)
 Find differences between first and second.
 
const char * ft_strnstr (const char *big, const char *little, size_t len)
 Search a substring in a bigger string, up to len position in string.
 
char * ft_strdup (const char *source)
 Create a copy of source into a new pointer NEEDS to be freed.
 
char * ft_strndup (const char *source, size_t len)
 Create a copy of source into a new pointer of size len NEEDS to be freed.
 
char * ft_substr (char const *src, unsigned int start, size_t len)
 Create a copy of source into a new pointer, at start, of size len NEEDS to be freed.
 
char * ft_strjoin (char const *s1, char const *s2)
 Allocates a new string, and returns the result of a concatenation of s1 and s2.
 
char * ft_strjoins (char **str)
 Allocates a new string, and returns the result of a concatenation of all the strings from the array last argument needs to be NULL.
 
char * ft_strtrim (char const *s, char const *set)
 Deletes all characters that exist in s and set, if they are at the beginning of the string or at the end.
 
char ** ft_split (char const *s, char c)
 Allocates with a malloc and returns an array of strings obtained by separating ’s’ using the character ’c’, used as a delimiter. The array must be terminated by NULL.
 
char * ft_strmapi (char const *s, char(*f)(unsigned int, char))
 Apply the function ’f’ to each character of the string ’s’, passing its index as first argument and the character itself as second argument.
 
void ft_striteri (char *s, void(*f)(unsigned int, char *))
 Iterate the function f on string s.
 

Detailed Description

String functions.

Function Documentation

◆ ft_split()

char ** ft_split ( char const * s,
char c )

Allocates with a malloc and returns an array of strings obtained by separating ’s’ using the character ’c’, used as a delimiter. The array must be terminated by NULL.

Parameters
sstring to print
cchar used as a delimiter
Returns
char** array of strings
Here is the call graph for this function:

◆ ft_strchr()

char * ft_strchr ( const char * string,
int searched_char )

Find first occurrence of searched_char.

Parameters
stringstring to search in
searched_charchar to search
Returns
char* index of Char found

◆ ft_strdup()

char * ft_strdup ( const char * source)

Create a copy of source into a new pointer NEEDS to be freed.

Parameters
sourcestring to copy
Returns
char* pointer to the new string
Here is the call graph for this function:

◆ ft_striteri()

void ft_striteri ( char * s,
void(* )(unsigned int, char *) )

Iterate the function f on string s.

Parameters
sstring to iterate
ffunction to apply

◆ ft_strjoin()

char * ft_strjoin ( char const * s1,
char const * s2 )

Allocates a new string, and returns the result of a concatenation of s1 and s2.

Parameters
s1string 1
s2string 2
Returns
char* new string
Here is the call graph for this function:

◆ ft_strjoins()

char * ft_strjoins ( char ** array)

Allocates a new string, and returns the result of a concatenation of all the strings from the array last argument needs to be NULL.

Parameters
arrayArray of strings
Returns
char* new string
Here is the call graph for this function:

◆ ft_strlcat()

size_t ft_strlcat ( char * dst,
const char * src,
size_t size )

Concatenate src into dst, up to size bytes.

Parameters
dstdestination string
srcsource string
sizesize of the destination string
Returns
unsigned int size of the new string
Here is the call graph for this function:

◆ ft_strlcpy()

size_t ft_strlcpy ( char * dst,
const char * src,
size_t size )

◆ ft_strlen()

size_t ft_strlen ( const char * the_string)

Len of string without '\0'.

Parameters
the_stringstring to check
Returns
size_t len of the string

◆ ft_strlen_char()

size_t ft_strlen_char ( const char * the_string,
int character )

Number of occurrence of character in the string.

Parameters
the_stringstring to check
charactercharacter to count
Returns
size_t len of the string

◆ ft_strmapi()

char * ft_strmapi ( char const * s,
char(* )(unsigned int, char) )

Apply the function ’f’ to each character of the string ’s’, passing its index as first argument and the character itself as second argument.

Parameters
sstring to iterate
ffunction to apply
Returns
char* new string
Here is the call graph for this function:

◆ ft_strncmp()

int ft_strncmp ( const char * first,
const char * second,
size_t length )

Find differences between first and second.

Parameters
firstfirst string to compare
secondsecond string to compare
lengthnumber of characters to compare
Returns
int value of first - second

◆ ft_strndup()

char * ft_strndup ( const char * source,
size_t len )

Create a copy of source into a new pointer of size len NEEDS to be freed.

Parameters
sourcestring to copy
lensize of the new string
Returns
char* pointer to the new string

◆ ft_strnstr()

const char * ft_strnstr ( const char * big,
const char * little,
size_t len )

Search a substring in a bigger string, up to len position in string.

Parameters
bigstring to search in
littlestring to search
lenmax size of big
Returns
char* pointer to the first occurence of little in big
Here is the call graph for this function:

◆ ft_strrchr()

char * ft_strrchr ( const char * string,
int searched_char )

Find last occurrence of searched_char.

Parameters
stringstring to search in
searched_charcharacter to search
Returns
char* pointer to the last occurrence of searched_char

◆ ft_strtrim()

char * ft_strtrim ( char const * s,
char const * set )

Deletes all characters that exist in s and set, if they are at the beginning of the string or at the end.

Parameters
sstring to trim
setstring of characters to trim
Returns
char* new string
Here is the call graph for this function:

◆ ft_substr()

char * ft_substr ( char const * src,
unsigned int start,
size_t len )

Create a copy of source into a new pointer, at start, of size len NEEDS to be freed.

Parameters
srcstring to copy
startstart of the copy
lensize of the copy
Returns
char* new string
Here is the call graph for this function: