[Solved] How to check if a set of characters are contained in a character array in C++?


See the code snippet for your understanding:

#include <iostream>
#include <string>
using namespace std;

int main() {
    string name;
    char arr[10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };

    bool found_a = false;
    bool found_b = false;
    bool found_c = false;

    for (int x = 0; x < 10; x++) {
        if( arr[x] == 'a' ) {
            found_a = true;
        } else if( arr[x] == 'b' ) {
            found_b = true;
        } else if( arr[x] == 'c' ) {
            found_c = true;
        }

        if(found_a == true && found_b == true && found_c == true) {
            cout << "Enter a name" << endl;
            cin >> name;
            if (name == "TEST") {
                for (int a = 0; a < 5; a++) {
                    cout << "TEST" << endl;
                }
            }
            break;
        }
    }
    system("pause");
    return 0;
}

solved How to check if a set of characters are contained in a character array in C++?