summaryrefslogtreecommitdiff
path: root/graphs/piscine/check_alphabet
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/piscine/check_alphabet
add: graphs et rushs
Diffstat (limited to 'graphs/piscine/check_alphabet')
-rw-r--r--graphs/piscine/check_alphabet/check_alphabet.c25
-rw-r--r--graphs/piscine/check_alphabet/check_alphabet.h6
2 files changed, 31 insertions, 0 deletions
diff --git a/graphs/piscine/check_alphabet/check_alphabet.c b/graphs/piscine/check_alphabet/check_alphabet.c
new file mode 100644
index 0000000..fc540b4
--- /dev/null
+++ b/graphs/piscine/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/graphs/piscine/check_alphabet/check_alphabet.h b/graphs/piscine/check_alphabet/check_alphabet.h
new file mode 100644
index 0000000..667a20f
--- /dev/null
+++ b/graphs/piscine/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 */