-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequal.c
More file actions
31 lines (26 loc) · 730 Bytes
/
equal.c
File metadata and controls
31 lines (26 loc) · 730 Bytes
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
#include <stdio.h>
// implicit return type
// implicit return value
// expression blocks
// empty bodied loops
//
// c is fun
eql (char *a, char *b) {
(a == b) + (!a && !b) || (a && b && ({while (*a++ && *b++ && *a == *b); !*a && !*b;}));
}
int main() {
char* a = "xyz";
char* b = "xyz";
char* c = "xym";
char* d = "myz";
char* e = "m";
char* f = NULL;
char* g = NULL;
printf(eql(a, b) ? "true\n" : "false\n");
printf(eql(a, c) ? "true\n" : "false\n");
printf(eql(a, d) ? "true\n" : "false\n");
printf(eql(a, e) ? "true\n" : "false\n");
printf(eql(a, f) ? "true\n" : "false\n");
printf(eql(c, d) ? "true\n" : "false\n");
printf(eql(f, g) ? "true\n" : "false\n");
}