builtins
This commit is contained in:
@@ -52,7 +52,7 @@ int ft_atoi(const char *str)
|
||||
int current_digit;
|
||||
|
||||
if (!str)
|
||||
return (-1);
|
||||
return (0);
|
||||
res = 0;
|
||||
i = 0;
|
||||
while (ft_isspace(str[i]))
|
||||
|
||||
@@ -15,23 +15,47 @@
|
||||
char *ft_strnstr(const char *haystack, const char *needle, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
int j;
|
||||
|
||||
i = 0;
|
||||
if (!haystack || !needle)
|
||||
return (NULL);
|
||||
if (needle[0] == 0)
|
||||
if (!haystack || !needle || *needle == 0)
|
||||
return ((char *)haystack);
|
||||
while (haystack[i] && i < len)
|
||||
{
|
||||
j = 0;
|
||||
while (haystack[i + j] == needle[j] && i + j < len)
|
||||
if (haystack[i] == needle[0])
|
||||
{
|
||||
j++;
|
||||
if (needle[j] == 0)
|
||||
return ((char *)(haystack + i));
|
||||
j = 0;
|
||||
while (haystack[i + j] == needle[j] && i + j < len)
|
||||
{
|
||||
j++;
|
||||
if (needle[j] == 0)
|
||||
return ((char *)(haystack + i));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
return (0);
|
||||
}
|
||||
// char *ft_strnstr(const char *haystack, const char *needle, size_t len)
|
||||
// {
|
||||
// size_t i;
|
||||
// size_t j;
|
||||
//
|
||||
// i = 0;
|
||||
// if (!haystack || !needle)
|
||||
// return (NULL);
|
||||
// if (needle[0] == 0)
|
||||
// return ((char *)haystack);
|
||||
// while (haystack[i] && i < len)
|
||||
// {
|
||||
// j = 0;
|
||||
// while (haystack[i + j] == needle[j] && i + j < len)
|
||||
// {
|
||||
// j++;
|
||||
// if (needle[j] == 0)
|
||||
// return ((char *)(haystack + i));
|
||||
// }
|
||||
// i++;
|
||||
// }
|
||||
// return (NULL);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user