Sort a string array with sort()
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string words[5] = { "ABCD", "BCDEF", "CERF","DERT", "EFRE"};
string* where;
where = find(words, words + 5, "CD");
cout << *++where << endl;
sort(words, words + 5);
where = find(words, words + 5, "ER");
cout << *++where << endl;
}
Related examples in the same category