3
I’m having some difficulty assigning a character to a certain position of string. I researched a lot before asking here and found nothing. Criticism is always welcome.
This function is a part of a hangman’s game that I’m doing which, if you hit the letter, should assign a character to a certain position of the string.
Obs. palavraAux
has the same number of characters as the palavra
and is filled with several "-".
bool acertou(char letra, string palavra, string *palavraAux, int *acertos) {
bool acerto = false;
for (int i = 0; i < palavra.length(); i++) {
if (letra == palavra[i]) {
acerto = true;
(*acertos)++;
palavraAux[i].push_back(letra); //Essa parte aqui
}
}
return acerto;
}
This would help you?String.Insert(Int32, String) Method
– Luiz Augusto
Help yes, I’ll take a look, thank you
– Vitor Carlos