mirror of
https://github.com/guezoloic/libft.git
synced 2026-01-25 06:34:14 +00:00
add ft_memchr function
This commit is contained in:
18
ft_memchr.c
Normal file
18
ft_memchr.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
void *ft_memchr(const void *s, int c, size_t n)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
const unsigned char *ptr;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
ptr = (const unsigned char *)s;
|
||||||
|
while (i < n)
|
||||||
|
{
|
||||||
|
if ((unsigned char)c == ptr[i])
|
||||||
|
return ((void*)(ptr+i));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
6
ft_strncmp.c
Normal file
6
ft_strncmp.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
// int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
15
libft.h
15
libft.h
@@ -88,7 +88,8 @@ void *ft_memmove(void *dst, const void *src, size_t n);
|
|||||||
*/
|
*/
|
||||||
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize);
|
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize);
|
||||||
|
|
||||||
// size_t ft_strlcat(char *dst, const char *src, size_t dstsize);
|
// TODO
|
||||||
|
size_t ft_strlcat(char *dst, const char *src, size_t dstsize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The ft_toupper() function converts a
|
The ft_toupper() function converts a
|
||||||
@@ -112,10 +113,20 @@ int ft_tolower(int c);
|
|||||||
char *ft_strchr(const char *s, int c);
|
char *ft_strchr(const char *s, int c);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The strrchr() function is identical
|
The ft_strrchr() function is identical
|
||||||
to strchr() except it locates the
|
to strchr() except it locates the
|
||||||
last occurrence of c.
|
last occurrence of c.
|
||||||
*/
|
*/
|
||||||
char *ft_strrchr(const char *s, int c);
|
char *ft_strrchr(const char *s, int c);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
int ft_strncmp(const char *s1, const char *s2, size_t n);
|
||||||
|
|
||||||
|
/*
|
||||||
|
he ft_memchr() function locates the
|
||||||
|
first occurrence of c (converted to
|
||||||
|
an unsigned char) in string s.
|
||||||
|
*/
|
||||||
|
void *ft_memchr(const void *s, int c, size_t n);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user