-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcomp.c
40 lines (37 loc) · 858 Bytes
/
dcomp.c
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
/*--------------------------------------------------------------*
* Compare two dictionaries
*--------------------------------------------------------------*/
#include "d2.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,
char *argv[])
{
Dict d1, d2;
const char *word;
int len;
if (argc != 3) {
fprintf(stderr, "Usage: %s dir1 dir2\n", argv[0]);
exit(1);
}
d1 = Dict_open(argv[1]);
d2 = Dict_open(argv[2]);
for (len=2; len<=MAXLEN; len++) {
Dscan ds = Dscan_open(d1, len);
while ((word = Dscan_read(ds)) != NULL) {
if (Dict_isword(d2, word, len)) {
;
}else if (len > 2 && word[len-1]=='S' &&
Dict_isword(d2, word, len-1)) {
;
}else{
printf("%s\n", word);
}
}
Dscan_close(ds);
}
Dict_close(d2);
Dict_close(d1);
return 0;
}