finished day
This commit is contained in:
1 parent
c29637ab4d
commit
12a7b354b9
36 files changed
+84
-16
No files matched your search
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4
-8
@@ -6,26 +6,22 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/08 14:52:06 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/11/09 14:27:32 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
#define BUFFER_SIZE 10
|
||||
|
||||
void *ft_memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (((char *)s)[i] && i < n)
|
||||
while (i < n)
|
||||
{
|
||||
if (((char *)s)[i] == (char)c)
|
||||
return (((char *)s + i));
|
||||
if (((unsigned char *)s)[i] == (unsigned char)c)
|
||||
return (((void *)s + i));
|
||||
i++;
|
||||
}
|
||||
if (c == 0)
|
||||
return (((char *)s) + i);
|
||||
return (NULL);
|
||||
}
|
||||
BIN
Binary file not shown.
+3
-1
@@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/08 12:16:47 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/11/09 14:06:17 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -18,6 +18,8 @@ int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
if (n == 0)
|
||||
return (0);
|
||||
while (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i] && i < n - 1)
|
||||
i++;
|
||||
return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
-1
@@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/08 14:31:21 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/11/09 14:31:55 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,5 +19,7 @@ char *ft_strchr(const char *s, int c)
|
||||
|
||||
len_s = ft_strlen(s);
|
||||
result = ft_memchr(s, c, len_s);
|
||||
if (c == 0)
|
||||
return ((char *)s + len_s);
|
||||
return (result);
|
||||
}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strnstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 16:02:17 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/09 13:58:30 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strnstr(const char *big, const char *little, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
if (!little || big == little)
|
||||
return ((char *)big);
|
||||
if (len <= 0)
|
||||
return (0);
|
||||
while (i < len && big[i])
|
||||
{
|
||||
j = 0;
|
||||
while (i + j < len && big[i + j] == little[j])
|
||||
j++;
|
||||
if (little[j] == 0)
|
||||
return ((char *)big + i);
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strrchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/08 15:21:28 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strrchr(const char *s, int c)
|
||||
{
|
||||
size_t i;
|
||||
size_t len_s;
|
||||
|
||||
len_s = ft_strlen(s);
|
||||
i = len_s;
|
||||
if (c == 0)
|
||||
return (&((char *)s)[len_s]);
|
||||
while (i > 0)
|
||||
{
|
||||
if (s[i] == (char)c)
|
||||
return (&((char *)s)[i]);
|
||||
i--;
|
||||
}
|
||||
if (s[0] == (char)c)
|
||||
return (&((char *)s)[0]);
|
||||
return (NULL);
|
||||
}
|
||||
Binary file not shown.
+5
-6
@@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/02 17:59:58 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/05 12:14:35 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/11/09 15:02:46 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -18,15 +18,14 @@ char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||
char *result;
|
||||
|
||||
i = 0;
|
||||
if (s == NULL || len == 0)
|
||||
if (s == NULL)
|
||||
return (NULL);
|
||||
if (start >= ft_strlen(s))
|
||||
if (start > ft_strlen(s))
|
||||
{
|
||||
result = malloc(1);
|
||||
result[0] = '\0';
|
||||
result = calloc(1, 1);
|
||||
return (result);
|
||||
}
|
||||
result = malloc((len + 1) * sizeof(char));
|
||||
result = malloc(((ft_strlen(s) - len) + 1) * sizeof(char));
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
while (i < len && s[start + i])
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user