blob: 5dc911c75f6bff5c624e09a91f12e87b7a4ff4ad (
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
55
56
57
58
59
60
61
62
63
64
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* inter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: exam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/07/19 17:20:35 by exam #+# #+# */
/* Updated: 2019/07/19 17:44:03 by exam ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int already_checked(char *str, int index)
{
char tested;
tested = str[index];
while (index-- > 0)
if (str[index] == tested)
return (1);
return (0);
}
int inside(char *str, char c)
{
while (*str)
{
if (c == *str)
return (1);
str++;
}
return (0);
}
int main(int argc, char **argv)
{
char *str1;
char *str2;
int i;
if (argc != 3)
{
write(1, "\n", 1);
return (0);
}
i = 0;
str1 = argv[1];
str2 = argv[2];
while (str1[i])
{
if (already_checked(str1, i))
{
i++;
continue ;
}
if (inside(str2, str1[i]))
write(1, &str1[i], 1);
i++;
}
write(1, "\n", 1);
return (0);
}
|