Insert char inside string

If player guess the right word, it should go into string
if not, should show used char
like: hat - player press a - _a_
player press z - not in char, used_letters - z.

Hope anyone out there can understand and help. pls
I need use basic C not C++

Thanks in advance.

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
void get_word_player2 (char word_player[], int size,char underscore[], int word_size)
{	
        //char underscore looks like: char underscore[SIZE] = {'_','_','_','_','_','_'}; in main
	int turns=10;
	int i,x, valid;
	char guess; 
	char used_letters[10] = {'\0'};   //why cant u put turns into []
	
	welcome_screen2();
		
	for (i=0; i < word_size; i++)
	{
		printf("\"%s\"", underscore);
	}
			
	
	for (x=0; x < turns; x++)
	{	
		for (i=0; i < word_size; i++)
		{	
			guess_word (word_player, size); //if this happens needs to get ou the loop
			
			get_input (guess, valid);
						
			if(guess != word_player[i])
			{
				printf("The letter \"%c\" is NOT the word\n", guess);
				used_letters[i] = guess;
				printf("These are the letters you have used: ");
				
				for (i=0; i < word_size; i++)
				{
					printf("\"%s\"", used_letters);
				}
			}
				
			else
				printf("The letter \"%c\" is IN the word\n", guess);
				underscore[i] = guess;
				
				for (i=0; i < word_size; i++)
				{
					printf("\"%s\"", underscore);
				}
			if(turns == 1)
				printf("last chance.\n");
		}
	}	
		
	return;
}
did anyone understand it??
If player guess the right word, it should go into string
if not, should show used char
like: hat - player press a - _a_
player press z - not in char, used_letters - z.


I didn't understand this
its a hangman game, using hat as example
I need to show
_ _ _
player enter 'a':

_ a _

player enter 'b':
wrong - letters used 'b'

hope i made it clear!!!
SOrry, but im really stress out!!!
why guess doesn't go into the array??
used_letters[i] = guess;

an then display = _a_
im super stuck, pls help
Topic archived. No new replies allowed.