Help with simple hangman

I started learning C++ in school this year ind I wanted to get some practice with doing some simple hangman game in console. I got stuck so I need help with the "if (input == character[n])" part where the program checks if the entered character is inside the randomized word. Thank you 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
52
53
54
55
	string words [] = {"computer","screen","mouse","phone","television"};
	bool repeatall=true;
	int n=0,random_number,max=4,min=0, word_lenght =0;
	string word,word2,yesorno;
	char character[200], input;

	while(repeatall==true)
	{
		int range = max - min + 1;
		random_number =rand() % range + min;
		word=words[random_number];
		word_lenght = word.length();
		cout<<word_lenght<<endl;
		while (word_lenght > 0)
		{
			while(word_lenght> 0)
			{
			strcpy_s(character,word.c_str());
			word_lenght--;
			}

			cout<<"Enter a character: ";
			cin>>input;

			if (input == character[n])
			{
				cout<<"The character is inside the word. Gongrats." <<endl;
				cout<<character[n]<<endl;

				break;
			}
			else 
				{
					n++;
					cout<<"The character isn`t inside the word. "<<endl;
				}
			
			word_lenght++;
		}
		
			
		

		cout<<"Y/N"<<endl;
		cin>>yesorno;
		if(yesorno == "y")
		{
			
		}
		else if(yesorno == "n")
		{
			repeatall=false;
		}
		n =0;
	}
Topic archived. No new replies allowed.