diff options
Diffstat (limited to 'rushs/evalexpr/check_alphabet')
| -rw-r--r-- | rushs/evalexpr/check_alphabet/check_alphabet.c | 25 | ||||
| -rw-r--r-- | rushs/evalexpr/check_alphabet/check_alphabet.h | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/rushs/evalexpr/check_alphabet/check_alphabet.c b/rushs/evalexpr/check_alphabet/check_alphabet.c new file mode 100644 index 0000000..fc540b4 --- /dev/null +++ b/rushs/evalexpr/check_alphabet/check_alphabet.c @@ -0,0 +1,25 @@ +#include "check_alphabet.h" + +#include <stddef.h> + +int check_alphabet(const char *str, const char *alphabet) +{ + if (alphabet == NULL || *alphabet == '\0') + { + return 1; + } + + for (int i = 0; alphabet[i]; i++) + { + int j; + for (j = 0; str[j] && str[j] != alphabet[i]; j++) + { + continue; + } + if (str[j] == '\0') + { + return 0; + } + } + return 1; +} diff --git a/rushs/evalexpr/check_alphabet/check_alphabet.h b/rushs/evalexpr/check_alphabet/check_alphabet.h new file mode 100644 index 0000000..667a20f --- /dev/null +++ b/rushs/evalexpr/check_alphabet/check_alphabet.h @@ -0,0 +1,6 @@ +#ifndef CHECK_ALPHABET_H +#define CHECK_ALPHABET_H + +int check_alphabet(const char *str, const char *alphabet); + +#endif /* !CHECK_ALPHABET_H */ |
