My Program's Loop Doesn't Do What I Intend It To Do

I do not understand what I have done wrong here. The problem is the bottom. My loop does not do what it is supposed to. You may wonder why all of those "if" statements are there. That is because I thought the "or" statements might have been the issue so I separated the conditional statements.

When I run it and input a bad value, it will not do anything. Earlier, if I put in a good value it acted as if it were bad. (Before I adjusted the code)

Please let me know what I did wrong with the code.
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
#include <iostream>

int main() {
	using namespace std;
	// restart
	char cSpace1 = '1';
	char cSpace2 = '2';
	char cSpace3 = '3';
	char cSpace4 = '4';
	char cSpace5 = '5';
	char cSpace6 = '6';
	char cSpace7 = '7';
	char cSpace8 = '8';
	char cSpace9 = '9';
	char cPlayer1;
	char cPlayer2;
	bool bValidInput;
	//to check for valid piece input
	do {
	cout << "Player One:  Choose X's or O's" << endl;
	cin >> cPlayer1;
	if (cPlayer1 == 'x') {
		bValidInput = true;
	}
	else if (cPlayer1 == 'X') {
		bValidInput = true;
	}
	else if (cPlayer1 == 'o') {
		bValidInput = true;
	}
	else if (cPlayer1 == 'O') {
		bValidInput = true;
	}
	else {
		bValidInput = false;
	} 
	if (bValidInput = false) {
		cout << "Please try again. Enter X or O" << endl;
		cout << endl;
	}
	}while(bValidInput = false);
Last edited on
By the way, I took out some code that was incomplete if you find some out of place comments. Also, when I tested the program, I did take out the incomplete code.
That was humorous, it is because I forgot the "==". I put one rather than two.
your will be answered too.. sometimes the answers are quick and sometimes they take time.. I would say a little bit of luck and patience.. :)
Topic archived. No new replies allowed.