Console HangMan game #include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;algorithm&gt;
#include &lt;time.h&gt;
int faults = 0;
int hangman(); 
int i = hangman();
int main(){


srand(time(NULL));
while (i == 1){
    std::string words[7]{"Alpha", "Cornwall", "Crepuscular", "Blind", "Steroid", "Plunder", "Talisman"};
    std::string word = words[rand() % 7];
    int n;

    n = rand() % word.length();
    char underscore = '_';
    char checkAnswer = word.at(n);
    word.at(n) = underscore;

    std::cout &lt;&lt; word;
    char answer;
    std::cin &gt;&gt; answer;


    if (answer == checkAnswer){
        std::cout &lt;&lt; "Correct!";
    }
    else{
        faults++;
        hangman();
    }
}






}
      int hangman(){
       if (faults == 0){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|" &lt;&lt; std::endl;
    return 1;
}
else if (faults == 1){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|" &lt;&lt; std::endl;
    std::cout&lt;&lt;"|" &lt;&lt; std::endl;
    return 1;
}
else if (faults == 2){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |"&lt;&lt;std::endl;
    std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|" &lt;&lt; std::endl;
        ;
    return 1;
}

else if (faults == 3){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                     /" &lt;&lt; std::endl;
        ;
    return 1;
}
else if (faults == 4){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
    return 1;
}
else if (faults == 5){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
        std::cout &lt;&lt; "                       -" &lt;&lt; std::endl;
    return 1;
}
else if (faults == 6){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
    std::cout &lt;&lt; "                      - -" &lt;&lt; std::endl;
    return 1;
}
else if (faults == 7){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
    std::cout &lt;&lt; "                      - -" &lt;&lt; std::endl;
    std::cout &lt;&lt; "Dead.Dead.The hangman is dead!You lose!" &lt;&lt; std::endl;
    return 0;
}
}
First of all, that's not how hangman is usually implimented, but I won't question it, I'll only review your code.

1. Make sure your code actually works

You currently have an endless while loop. Your hangman() function does not do what it's supposed to, it does not update the value of i. Remove the 'i' variable entirely and change the main loop to "while(hangman()) { ... }". You should also remove the hangman() call at the end of your while loop (in the 'else' block), because it's not needed after this adjustment. 

(note: that's the least  you should do. I'd suggest avoiding global variables entirely (you'll still have a global variable 'faults'), but changing that would require redesigning the whole code. You should at least change 'faults' to 'g_faults' to indicate that it's a global variable)

2. Adjust the output of your program

This is sort of a minor nitpick, but your output looks ugly. A space before user input and a newline char after 'correct!' should fix it.

3. Properly indent your code

Your code as it currently is is hard to read and understand, because it does not follow the common identation rules. I'll post your code with proper indentation later.

4. Don't use the NULL macro

Especialy in this situation, there is no need for it (correct me if I'm wrong). Simply write 'time(0)'.

5. Name your variables properly

The name of your variable should make clear what the varable does. Thus, your 'word' string should be 'current_word' or at least 'cWord', the 'checkAnswer' char should be 'currentLetter' or 'missingLetter' ect.

Sorta fixed code

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;algorithm&gt;
#include &lt;time.h&gt;

int faults = 0;
int hangman();

// No need for 'i' variable

int main(){
    // No need for NULL macro
    srand(time(0));

    // If you declare words[] inside the while loop, it gets created and destroyed every time the loop
    // executes. There is no need for that, thus you should declare the array outside of the loop
    std::string words[7]{"Alpha", "Cornwall", "Crepuscular", "Blind", "Steroid", "Plunder", "Talisman"};

    while (hangman()){
        std::string word = words[rand() % 7];

        // No need to separately declare and initialize the 'n' variable
        int n = rand() % word.length();
        char checkAnswer = word.at(n);

        // No need for an underscore variable, because you only use it once in your code.
        // One could argue that you should still keep the variable in case you wanted to change the
        // symbol, but your variable name indicates that it equals to '_', so you wouldn't use it
        // for that.(What I meant is if you wanted to change "A_pha" to, let's say, "A*pha")
        word.at(n) = '_';

        std::cout &lt;&lt; word &lt;&lt; ' ';
        char answer;
        std::cin &gt;&gt; answer;

        if (answer == checkAnswer){
            std::cout &lt;&lt; "Correct!\n";
        }
        else{
            // Prefer ++a to a++. It doesn't matter in this case, but it's a good practice
            ++faults;
        }
    }
}

int hangman(){
    // Switch statement may have been more fitting here, but I'm too lazy to rewrite
    // your code, so do it yourself if you want to :P
    if (faults == 0){
    std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|" &lt;&lt; std::endl;
    std::cout &lt;&lt; "|" &lt;&lt; std::endl;
    return 1;
    }
    else if (faults == 1){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|" &lt;&lt; std::endl;
        std::cout&lt;&lt;"|" &lt;&lt; std::endl;
        return 1;
    }
    else if (faults == 2){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |"&lt;&lt;std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|" &lt;&lt; std::endl;
            ;
        return 1;
    }

    else if (faults == 3){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                     /" &lt;&lt; std::endl;
            ;
        return 1;
    }
    else if (faults == 4){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
        return 1;
    }
    else if (faults == 5){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
            std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
            std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
            std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
            std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
            std::cout &lt;&lt; "                       -" &lt;&lt; std::endl;
        return 1;
    }
    else if (faults == 6){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
        std::cout &lt;&lt; "                      - -" &lt;&lt; std::endl;
        return 1;
    }
    else if (faults == 7){
        std::cout &lt;&lt; "|----------------------" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      O" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      |" &lt;&lt; std::endl;
        std::cout &lt;&lt; "|                      X" &lt;&lt; std::endl;
        std::cout &lt;&lt; "                      - -" &lt;&lt; std::endl;
        std::cout &lt;&lt; "Dead.Dead.The hangman is dead!You lose!" &lt;&lt; std::endl;
        return 0;
    }
    // Again, just a design nitpick, but your images of hangman with 6 and 7 faults are identical.
    // Shouldn't the hangman be dead after 6 faults then?
}