Write your question here.
I am trying to make a part of the game hangman, where the user inputs a letter and then a loop check for that letter in a random array. If the letter is found, it then couts it, but if it is not there, then it couts << " _ ", as in blank. This is for a hangman game and offers the user to again, input another letter. It seems for loops are not wworking since the output here is:
Enter a Letter:
a
_ Enter a Letter:
_ Enter a Letter:
00000Enter a Letter:
_ Enter a Letter:
_ Enter a Letter:
_ Enter a Letter:
00000Enter a Letter:
00000Program ended with exit code: 0
my code is not working properly and I don't know why.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
for(int v = 0; v < 8; v++){
cout << "Enter a Letter: " << endl;
cin >> ugib[v];
if(ugib[v] == geslo[v]){
for(int b = 0; b < 5; b++){
cout << ugib[v];
}
}
else{
cout << " _ ";
}
}
Can anyone help me with the code, i dont know what I am doing wrong. thanks.