Skip to content

Instantly share code, notes, and snippets.

@alepez
Created June 14, 2019 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alepez/c42eeb83c5a7169c0b11f13071eca061 to your computer and use it in GitHub Desktop.
Save alepez/c42eeb83c5a7169c0b11f13071eca061 to your computer and use it in GitHub Desktop.
string compare with human readable diff
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