C++ program to sort strings alphabetically - CodeVsColor
www.codevscolor.com › c-plus-plus-sort-stringsWe can simply pass the start and end positions to sort all strings alphabetically. We will use a vector to store the strings: # include <iostream> # include <algorithm> # include <vector> # include <string> using namespace std ; int main ( ) { vector < string > strArray = { "dog" , "cat" , "apple" , "banana" } ; sort ( strArray . begin ( ) , strArray . end ( ) ) ; for ( int i = 0 ; i < strArray . size ( ) ; i ++ ) cout << strArray [ i ] << endl ; return 0 ; }