-1
Hi guys. I have a problem regarding a specific part of the game, which is already complete. The only problem is the condition I put to check if the word was completely guessed. My code:
if (strchr(palavra,letra[0])!= NULL) {
ptr =strchr(palavra, letra[0]);
while(ptr != NULL){
i = (ptr-palavra);
ptr = strchr(ptr+1, letra[0]);
tela[i] = letra[0];
acert++;
}
for(i=0;i<strlen(palavra);i++){
cout << "\t" << tela[i];
}
}
else {
cout << "\n\tletra errada.\n";
max++;
}
The acert++
counts how many letters were hit and if the number of letters is equal to the word size, it says that Voce won.
The problem is that as he goes through this condition every time the letter is hit, if someone types the same letter repeatedly, he counts that same letter right more than once.
How can I say that:
If letter not contained in array that displays word count acert++
OR
If letter ja contained in array that displays word not count acert++
I think the first way is easier to increase, just do not know how. Any help is welcome. I thank you already.
thinking logically would no longer be valid a condition that checks whether the letter repeats itself 2 or 3 times followed, with this the
acert++
would change toacert--
it removes 1 or more hits, causing the repeated letters not to be counted as certain.– gleisin-dev
That may be, but how do I write this condition? "condition that checks whether the letter repeats 2 or 3 times in a row". That is my central doubt.
– user237530
Cara don’t know how to solve in C++, but what you can do is create a variable to count which letters have already been chosen and not let repeat letter
– SantoJoao
@user237530 friend gets a little difficult only with a part of the code, would have to make it available in full?
– gleisin-dev