Hangman Project

Hello! I am pretty new with the C++ language and programming all together and I am having difficulty with this hangman project I am working on. The program should read in a word from a file and put it into a char array. Then a complement array should be displayed using '*' notating each letter. I am having success with every letter except the last where it just isn't working. I am stumped... Any help or pointers would be appreciated. Note: This is not the final format of the program (I know it's pretty gross looking haha)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using namespace std;
void open_and_hide(char word_string[10], int& letters_of_word, char solution[]);
void guessing(int wrong_attempts[], char word_string[10], char solution[]);


ifstream word_file;

int main()
{
    int MAX = 6;
    int wrong_guesses[MAX];
    int letters_of_word;
    char word_to_be_guessed[10];
    char solution_guessed[10];
    
    open_and_hide(word_to_be_guessed, letters_of_word, solution_guessed);
    for(int i = 0; i < MAX; i++)
    {
        cout<<endl;
        guessing(wrong_guesses, word_to_be_guessed, solution_guessed);
    }
}

//Opening file with words and masking them with *.
void open_and_hide(char word_string[10], int& letters_of_word, char solution[])
{

    char next;
    int index = 0;

    
    word_file.open("wordlist.dat");
    while (next != '\n')
    {
        
        word_file.get(next);
        word_string[index] = next;
        index++;
        
    }

    cout<<word_string;
    
    
    for (int i = 0; i < (index-1); i++)
    {
        solution[i] = '*';
        
    }
    cout<<solution;
    letters_of_word = index-1;
}

void guessing(int wrong_attempts[], char word_string[10], char solution[])
{
    char guess;
    cout<<"guess: ";
    cin>>guess;
    
    for(int i = 0; i < 6; i++)
    {
        if (guess == word_string[i])
            solution[i] = word_string[i];
        
    }
    cout<<solution;
    
}
Found the fix myself.... After taking a break and coming back to it haha
for(int i = 0; i <= 6; i++)
Topic archived. No new replies allowed.