54 lines
921 B
C
54 lines
921 B
C
#include "main.h"
|
|
|
|
/**
|
|
* _strlen - Takes string and return its length
|
|
*
|
|
* @str: Address to the head of the string (Array of Characters) (Lost btw)
|
|
*
|
|
* Return: Length of String
|
|
*/
|
|
int _strlen(const char *str)
|
|
{
|
|
if (*str)
|
|
return (1 + _strlen(++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(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);
|
|
}
|
|
|
|
/**
|
|
* append - shoved character at the end
|
|
*
|
|
* @str: main string
|
|
* @c: character getting shoved
|
|
*
|
|
* Return: da string but appended
|
|
*/
|
|
|
|
void append(char *str, char c)
|
|
{
|
|
int len = _strlen(str);
|
|
*(str + len) = c;
|
|
*(str + len + 1) = '\0';
|
|
}
|