String diff
/*
* File: diff.cpp
* Author: borovec
*
* Created on 18. listopad 2008, 16:29
*/
#include <iostream>
using namespace std;
bool diff ( const char * s1, const char * s2, bool cs ){
while(*s1!='\0' || *s2!='\0'){
if(isspace(*s1)){
s1++;
continue;
}
if(isspace(*s2)){
s2++;
continue;
}
if(cs){
if(*s1!=*s2) return false;
}else {
if(*s1!=*s2 && toupper(*s1)!=*s2 && tolower(*s1)!=*s2) return false;
}
s1 ++;
s2 ++;
}
return true;
}
/*
*
*/
int main(int argc, char** argv) {
cout << diff ( "Stejne retezce", " S t e\tjn\ner e tezc\te ", true );
// true
cout << diff ( "Stejne retezce", " S t e\tjn\ner e tezc\te ", false );
// true
cout << diff ( "Stejne retezce", " S T e\tJn\neR e TeZC\te ", false );
// true
cout << diff ( "Rozdilne retezce", " R\to\tzd i l n e R e te z\nce", true );
// false
cout << diff ( " Rozdilne retezce ", " Ruzne retezce", false );
// false
cout << diff ( "Stejne retezce", " S T e\tJn\neR e TeZC\te ", true );
// false
return (EXIT_SUCCESS);
}