Skip to main content
added 64 characters in body
Source Link
HaveNoDisplayName
  • 8.5k
  • 106
  • 41
  • 50

An easy way to compare strings that are only different by lowercase and capitalized characters is to do an ascii comparison. All capital and lowercase letters differ by 32 bits in the ascii table, using this information we have the following...

 for( int i = 0; i < string2.length(); i++)  {   if (string1[i] == string2[i] || int(string1[i]) == int(string2[j])+32 ||int(string1[i]) == int(string2[i])-32)  {   count++;   continue;  }  else  {   break;  }  if(count == string2.length())  {   //then we have a match } } 

}

An easy way to compare strings that are only different by lowercase and capitalized characters is to do an ascii comparison. All capital and lowercase letters differ by 32 bits in the ascii table, using this information we have the following...

for( int i = 0; i < string2.length(); i++) { if (string1[i] == string2[i] || int(string1[i]) == int(string2[j])+32 ||int(string1[i]) == int(string2[i])-32) { count++; continue; } else { break; } if(count == string2.length()) { //then we have a match } 

}

An easy way to compare strings that are only different by lowercase and capitalized characters is to do an ascii comparison. All capital and lowercase letters differ by 32 bits in the ascii table, using this information we have the following...

 for( int i = 0; i < string2.length(); i++)  {   if (string1[i] == string2[i] || int(string1[i]) == int(string2[j])+32 ||int(string1[i]) == int(string2[i])-32)  {   count++;   continue;  }  else  {   break;  }  if(count == string2.length())  {   //then we have a match } } 
Source Link

An easy way to compare strings that are only different by lowercase and capitalized characters is to do an ascii comparison. All capital and lowercase letters differ by 32 bits in the ascii table, using this information we have the following...

for( int i = 0; i < string2.length(); i++) { if (string1[i] == string2[i] || int(string1[i]) == int(string2[j])+32 ||int(string1[i]) == int(string2[i])-32) { count++; continue; } else { break; } if(count == string2.length()) { //then we have a match } 

}