blob: 96242c94344e19d90b998a441e6c8c1d09979c07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
}
|