aboutsummaryrefslogtreecommitdiff
path: root/exam01/rendu/wdmatch
diff options
context:
space:
mode:
authorCabergs Charles <cacharle@e-r6-p7.s19.be>2019-07-16 12:58:13 +0200
committerCabergs Charles <cacharle@e-r6-p7.s19.be>2019-07-16 12:58:13 +0200
commit66635d69fa00e335a091d7e6f2b358cbaaf205e4 (patch)
tree3ecf5a41b4541980ba0287a431681cd5ae25ad84 /exam01/rendu/wdmatch
parent11114fd684250943de56c4f73ab45c97f2aaf83a (diff)
downloadpiscine-66635d69fa00e335a091d7e6f2b358cbaaf205e4.tar.gz
piscine-66635d69fa00e335a091d7e6f2b358cbaaf205e4.tar.bz2
piscine-66635d69fa00e335a091d7e6f2b358cbaaf205e4.zip
c09 passed, c10 start, exam00 and exam01
Diffstat (limited to 'exam01/rendu/wdmatch')
-rwxr-xr-xexam01/rendu/wdmatch/wdmatch.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/exam01/rendu/wdmatch/wdmatch.c b/exam01/rendu/wdmatch/wdmatch.c
new file mode 100755
index 0000000..96242c9
--- /dev/null
+++ b/exam01/rendu/wdmatch/wdmatch.c
@@ -0,0 +1,54 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* wdmatch.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/12 17:25:25 by exam #+# #+# */
+/* Updated: 2019/07/12 17:57:14 by exam ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+
+int in_charset(char c, char *charset)
+{
+ while (*charset)
+ if (c == *charset++)
+ return (1);
+ return (0);
+}
+
+int main(int argc, char **argv)
+{
+ int i;
+ int j;
+ char *str;
+ char *charset;
+
+ if (argc != 3)
+ {
+ write(1, "\n", 1);
+ return (0);
+ }
+ str = argv[1];
+ charset = argv[2];
+ i = 0;
+ j = 0;
+ while (str[i])
+ {
+ if (!in_charset(str[i], charset))
+ {
+ write(1, "\n", 1);
+ return (0);
+ }
+ while (*charset != str[i])
+ charset++;
+ i++;
+ }
+ while (*str)
+ write(1, str++, 1);
+ write(1, "\n", 1);
+ return (0);
+}