Created
June 14, 2019 10:06
-
-
Save alepez/c42eeb83c5a7169c0b11f13071eca061 to your computer and use it in GitHub Desktop.
string compare with human readable diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool stringsCompare(const std::string& a, const std::string& b) | |
{ | |
for (int i = 0; i < a.size() && i < b.size(); ++i) | |
{ | |
if (a[i] != b[i]) | |
{ | |
fprintf(stderr, "At index %i: %c != %c\n", i, a[i], b[i]); | |
return false; | |
} | |
else | |
{ | |
fprintf(stderr, "%c", a[i]); | |
} | |
} | |
return a == b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment