// demo program using vector container and sort #include // std::cout, std::cin #include // std::vector #include // std::string #include // std::sort int main(int argc, char const *argv[]) { // create a vector/array of strings std::vector words; // collect string from stdin std::string input; while (std::cin >> input) { // nulptr on EOF words.push_back(input); } // sort words std::sort(words.begin(), words.end()); // print to stdout for (std::string & word : words) { std::cout << "<" + word + ">" << std::endl; } /* // works too for (auto it = words.begin(); it != words.end(); ++it) { std::cout << "<" + *it + ">" << std::endl; } */ return EXIT_SUCCESS; }