-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path2_wdmatch.c
More file actions
executable file
·62 lines (58 loc) · 1.48 KB
/
2_wdmatch.c
File metadata and controls
executable file
·62 lines (58 loc) · 1.48 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* wdmatch.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: exam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/09 09:13:29 by exam #+# #+# */
/* Updated: 2018/10/09 09:30:29 by exam ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
char stack[1256];
int pointer = -1;
void pc(char c)
{
write(1, &c, 1);
}
int main(int ac, char **av)
{
if (ac != 3)
{
pc('\n');
return (0);
}
else
{
int j = 0;
int temp = 0;
char c = 0;
for (int i = 0; av[1][i]; i++)
{
c = av[1][i];
if (!av[2][j])
{
pc('\n');
return (0);
}
for (j = temp; av[2][j]; j++)
{
if (av[2][j] == c)
{
stack[++pointer] = av[2][j++];
temp = j;
break ;
}
}
if (j != temp)
{
pc('\n');
return (0);
}
}
write(1, stack, pointer + 1);
pc('\n');
}
return (0);
}