yo/stl/examples/strcasecmp.cc
raw| 1 | #include <iostream> |
| 2 | #include <string> |
| 3 | #include <cstring> |
| 4 | #include <algorithm> |
| 5 | using namespace std; |
| 6 | |
| 7 | class CaseInsensitive |
| 8 | { |
| 9 | public: |
| 10 | bool operator()(string const &left, string const &right) const |
| 11 | { |
| 12 | return strcasecmp(left.c_str(), right.c_str()) < 0; |
| 13 | } |
| 14 | }; |
| 15 | int main(int argc, char **argv) |
| 16 | { |
| 17 | sort(argv, argv + argc, CaseInsensitive{}); |
| 18 | for (int idx = 0; idx < argc; ++idx) |
| 19 | cout << argv[idx] << " "; |
| 20 | cout << '\n'; |
| 21 | } |