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
#include <stdio.h>
int my_strcmp(char *s, char *t) {
	int sub;
	while (*s) {
		sub = *s - *t;
		if (sub != 0) return sub;
		s++; t++;
	}
	return *s - *t;
}
void main() {
	char buf[50];
	char words[2][20];
	int result;
	while (1) {
		printf("input 2 words > ");
		fgets(buf, 50, stdin);
		if (sscanf(buf, "%19s %19s", words[0], words[1]) != 2) break;
		result = my_strcmp(words[0], words[1]);
		if (result < 0) printf("first is small.\n");
		else if (result > 0) printf("first is big.\n");
		else printf("first equals second.\n");
	}
}