Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Semrush - keyword research tool

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Teach Your Child To Read

Disclosure: My content contains affiliate links.

31,649 questions

41,702 answers

573 users

How to find the duplicate strings in STL array of strings with C++

1 Answer

0 votes
#include <iostream>
#include <string>
#include <array>

int main() {
    std::array<std::string, 7> arr {"C++ is a high-level, general-purpose programming language", 
        "created by Danish computer scientist Bjarne Stroustrup", 
        "C++ is a high-level, general-purpose programming language",
        "Multi-paradigm: procedural, imperative, functional", 
        "object-oriented, generic, modular",
        " C++23 / 19 March 2023",
        "object-oriented, generic, modular"
    }; 

    int size = sizeof(arr)/sizeof(arr[0]);

    for (int i = 0; i < size; i++) {
        for (int j = i + 1; j < size; j++) {
            if (arr[i] == arr[j]) {
                std::cout <<  "line " << i << " and line " << j << " = " << arr[i] << "\n";
            }
        }
    }
}



/*
run:

line 0 and line 2 = C++ is a high-level, general-purpose programming language
line 4 and line 6 = object-oriented, generic, modular

*/

 



Learn & Practice Python
with the most comprehensive set of 13 hands-on online Python courses
Start now


answered Jul 6 by avibootz

Related questions

3 answers 33 views
33 views asked Feb 23, 2023 by avibootz
1 answer 79 views
1 answer 43 views
...