How to check if all strings are lexically equal in array of strings with C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    std::vector <std::string> strings = {"c++", "c++", "c++", "c++", "c++"};

    std::cout << std::all_of( ++(strings.begin()), strings.end(),
                    [&](std::string x){ return x == strings.front(); } );
}




/*
run:

1

*/

 



answered Aug 12, 2023 by avibootz
...