/*
Nome: Mario
Cognome: Montanari

strncmp()
*/

#include <iostream>

#define SIZE 40

using namespace std;

int strncmp(const char *src1, const char *src2, int count);

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 = strncmp(src1, src2, 1);
	
	if (result == 0) {
		cout << "src1 = src2" << endl;
	} else if (result < 0) {
		cout << "src1 < src2" << endl;
	} else {
		cout << "src1 > src2" << endl;
	}
	
	return 0;
}

int strncmp(const char *src1, const char *src2, int count) {
	int i = 0;
	
	while (i < count && src1[i] != '\0' && src2[i] != '\0') {
		if (src1[i] != src2[i]) {
			return src1[i] - src2[i];
		}
		i++;
	}
	
	if (i < count) {
		return src1[i] - src2[i];
	}
	
	return 0;
}