Guest claudiuhks Posted May 14, 2012 Posted May 14, 2012 strcasecontain intoarce true daca ccSubString este inclusa in ccString fara a tine cont de dimensiunea literelor! strcontain intoarce true daca ccSubString este inclusa in ccString tinand cont de dimensiunea literelor! bool strcasecontain( const char *ccString, const char *ccSubString ){ const char *ccCopyOfString = ccString, *ccSecondCopyOfString = ccString, *ccCopyOfSubString = ccSubString, *ccSecondCopyOfSubString = ccSubString; while( *ccSecondCopyOfString ) { if( tolower( *ccSecondCopyOfString ) == tolower( *ccCopyOfSubString ) ) { ccSecondCopyOfString++; if( !*++ccCopyOfSubString ) return true; } else ccSecondCopyOfString = ++ccCopyOfString, ccCopyOfSubString = ccSecondCopyOfSubString; } return false;} bool strcontain( const char *ccString, const char *ccSubString ){ const char *ccCopyOfString = ccString, *ccSecondCopyOfString = ccString, *ccCopyOfSubString = ccSubString, *ccSecondCopyOfSubString = ccSubString; while( *ccSecondCopyOfString ) { if( *ccSecondCopyOfString == *ccCopyOfSubString ) { ccSecondCopyOfString++; if( !*++ccCopyOfSubString ) return true; } else ccSecondCopyOfString = ++ccCopyOfString, ccCopyOfSubString = ccSecondCopyOfSubString; } return false;}
Guest claudiuhks Posted May 14, 2012 Posted May 14, 2012 Iata si un exemplu: int main( ){ if( strcasecontain( "NewLifeZM.CsBlackDevil.Com [Zombie Plague]", "newLifeZM.CsBlackDevil.Com" ) ) { /* "NewLifeZM.CsBlackDevil.Com [Zombie Plague]" contains string "newLifeZM.CsBlackDevil.Com" (without quotes) -- ignoring the characters size */ } return 1;}
Recommended Posts