contains implemented

This commit is contained in:
LinlyBoi
2023-08-19 22:27:49 +03:00
parent 6a7403a7c4
commit 92738bbd3d
2 changed files with 22 additions and 1 deletions

2
main.h
View File

@@ -1,7 +1,7 @@
#ifndef MAIN_H_
#define MAIN_H_
int _printf(const char *format, ...);
int _contains(char *str);
int _contains(char *str, char c);
int _strlen(char *str);

View File

@@ -14,3 +14,24 @@ int _strlen(char *str)
else
return (0);
}
/**
* _contains - gets number of unique identifiers
*
* @str: da string
* @c: basically almost always '%'
*
* Return: number of unique cases of "%*" that aren't "%%"
*/
int _contains(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);
}