add: str_contain_only

This commit is contained in:
starnakin 2023-06-28 21:03:08 +02:00
parent 651de74c27
commit 13f3bb0730
2 changed files with 13 additions and 0 deletions

View File

@ -4,3 +4,5 @@
#include <stdlib.h>
char **split(const char *str, const char *delimiter);
int str_contain_only(const char *str, const char *charset);

View File

@ -0,0 +1,11 @@
#include "./str.h"
int str_contain_only(const char *str, const char *charset)
{
for (size_t i = 0; str[i] != '\0'; i++)
{
if (strchr(charset, str[i]) == NULL)
return 0;
}
return 1;
}