7 void debug(const char *fmt
, ...) {
11 vfprintf(stderr
, fmt
, ap
);
16 static void compare(const char *a
, const char *b
) {
17 const char *p
= a
, *q
= b
;
25 debug(" comparing %s and %s: %d\n", a
, b
, diff
);
33 int main(int argc
, char **argv
) {
35 size_t size
= 0, len
= 0;
40 stdin
= freopen(argv
[1], "r", stdin
);
42 while (getline(&line
, &len
, stdin
) >= 0) {
43 list
= reallocarray(list
, ++size
, sizeof *list
);
44 list
[size
- 1] = strdup(line
);
46 printf("read %zd lines\n", size
);
47 for (i
= 0; i
< size
; i
++)
48 for (j
= i
+ 1; j
< size
; j
++)
49 compare(list
[i
], list
[j
]);
50 printf("no nearby found\n");