/*3. Write a function, int strcmp(const char* s1, const char* s2), 
that compares C-style strings. Let it return a negative number if 
s1 is lexicographically before s2, zero if s1 equals s2,
and a positive number if s1 is lexicographically after s2. 
Do not use any standard library functions. 
Do not use subscripting; use the dereference operator * instead.
*/

#include <iostream>
using namespace std;

#define MAXLENGTH 10000

int strcmp(const char* s1, const char* s2) {
	while (*s1 == *s2 && *s1 && *s2) {
		++s1;
		++s2;
	}
	if (!*s1 && !*s2) return 0;
	else if (!*s1 || *s1 < *s2) return 1;
	else return -1;
}

int main() {
	cout << "Enter two strings:\n";
	char* s1 = new char[MAXLENGTH];
	char* s2 = new char[MAXLENGTH];
	cin.getline(s1, MAXLENGTH);
	while (cin.getline(s2, MAXLENGTH)) {
		cout << strcmp(s1, s2) << endl;
		cout << "Enter two strings:\n";
		cin.getline(s1, MAXLENGTH);
}

}
