fixed some stuff (100%)
This commit is contained in:
28
strings.c
28
strings.c
@@ -5,14 +5,14 @@
|
||||
*
|
||||
* @str: Address to the head of the string (Array of Characters) (Lost btw)
|
||||
*
|
||||
* Returns: Length of String
|
||||
* Return: Length of String
|
||||
*/
|
||||
int _strlen(const char *str)
|
||||
{
|
||||
if (*str)
|
||||
return (1 + _strlen(++str));
|
||||
else
|
||||
return (0);
|
||||
if (*str)
|
||||
return (1 + _strlen(++str));
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,13 +25,13 @@ int _strlen(const char *str)
|
||||
*/
|
||||
int _contains(const char *str, char c)
|
||||
{
|
||||
if (*str)
|
||||
{
|
||||
if (*str == c && *(str + 1) != c && *(str - 1) != c)
|
||||
return (1 + _contains(str + 1, c));
|
||||
else
|
||||
return (_contains(str + 1, c));
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
if (*str)
|
||||
{
|
||||
if (*str == c && *(str + 1) != c && *(str - 1) != c)
|
||||
return (1 + _contains(str + 1, c));
|
||||
else
|
||||
return (_contains(str + 1, c));
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user