std::strcmp
Min standard notice:
Header: <cstring>
Compares two null-terminated byte strings lexicographically.
# Declarations
int strcmp( const char* lhs, const char* rhs );
# Parameters
lhs, rhs: pointers to the null-terminated byte strings to compare
# Return value
Negative value if lhs appears before rhs in lexicographical order.
# Example
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
int main()
{
std::vector<const char*> cats{"Heathcliff", "Snagglepuss", "Hobbes", "Garfield"};
std::sort(cats.begin(), cats.end(), [](const char* strA, const char* strB)
{
return std::strcmp(strA, strB) < 0;
});
for (const char* cat : cats)
std::cout << cat << '\n';
}