#include <iostream>
using namespace std;
bool cmpstringz0rs(char * s1, char * s2, int lens1, int lens2)
{
if (lens1 != lens2) return false;
for (int i=0; i<lens1; i++)
{
if ((*s1++)!=(*s2++)) return false;
}
return true;
}
void main (void)
{
char string1[]= {"Hello there"};
char string2[]= {"Hi there"};
bool result = cmpstringz0rs( string1, string2, sizeof(string1), sizeof(string2) );
if (result) cout << "equal";
else cout << "not equal";
return;
} |