42_cube3D/libftx/extra/ft_contain_only.c

42 lines
1.2 KiB
C
Raw Normal View History

2023-04-26 07:02:44 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_contain_only.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/12 16:28:20 by cchauvet #+# #+# */
2023-05-03 07:11:04 -04:00
/* Updated: 2023/04/26 13:07:06 by cchauvet ### ########.fr */
2023-04-26 07:02:44 -04:00
/* */
/* ************************************************************************** */
#include "extra.h"
2023-05-03 07:11:04 -04:00
int ft_contain_only(const char *str, char c)
2023-04-26 07:02:44 -04:00
{
size_t i;
i = 0;
while (str[i] != '\0')
{
if (str[i] != c)
return (0);
i++;
}
return (1);
}
2023-05-03 07:11:04 -04:00
int ft_contain_only_str(const char *str, const char *to_find)
2023-04-26 07:02:44 -04:00
{
size_t i;
i = 0;
while (str[i] != '\0')
{
if (!ft_is_in(to_find, str[i]))
return (0);
i++;
}
return (1);
}