/*
Nome: Mario
Cognome: Montanari

strcasecmp()
*/

#include <iostream>
#include <cstring>
#include <cctype>

#define SIZE 100+1

using namespace std;

int strcasecmp(const char *src1, const char *src2);

int main(void) {
	char src1[SIZE];
	char src2[SIZE];
	int result;
	
	cout << "Inserisci una prima frase: ";
	cin.getline(src1, SIZE);
	
	cout << "Inserisci una seconda frase: ";
	cin.getline(src2, SIZE);
	
	result = strcasecmp(src1, src2);
	
	if (result == 0) {
		cout << endl << "src1 = src2" << endl;
	} else if (result < 0) {
		cout << endl << "src1 < src2" << endl;
	} else {
		cout << endl  << "src1 > src2" << endl;
	}
	
	return 0;
}

int strcasecmp(const char *src1, const char *src2) {
	while (*src1 && src2) {
		char chr1 = tolower(*src1);
		char chr2 = tolower(*src2);
		
		if (chr1 != chr2) {
			return chr1 - chr2;
		}
		
		src1++;
		src2++;
	}
	
	return tolower(*src1) - tolower(*src2);
}