There is a program that should display the word, where the letters are replaced by the '_' character and the user one letter guesses this word. The problem is that the program displays only 1 letter and is also replaced only one at a time and after entering a word, the letters do not stop working. Help me find a bug.
string[] slovo = new string [] {"algoritm"}; char[] guess = new char[slovo.Length]; for (int p = 0; p < slovo.Length; p++) guess[p] = '_'; while(true) { Console.WriteLine(guess); char bukva = Convert.ToChar(Console.ReadLine()); for (int j=0; j < slovo.Length; j++) { if (slovo[j].Contains(bukva)) guess[j] = bukva; else Console.WriteLine("Takoj bukvi net!"); } }
string[] slovo = new string [] {"algoritm"};- why array? accordinglyfor (int p = 0; p < slovo.Length; p++)- cycle from 0 to 0 - slippyk