how to check if an array contains no dashes

hi …
i have a vector called dashvector for my hangman game. if the user guesses a letter correctly all of the same letters get “revealed”. how do i make it so that once the array has no more dashes the program closes.

bool has_dash(const vector<char> &dashvector) {
    // Go over every element in the vector.
    for (const char c : dashvector) {
        // If we hit a dash, then we're done.
        if (c == '-')
            return true;
    }
    // If we haven't found a dash at this point, then the whole array has no dashes.
    return false;
}
1 Like