I am offering the player a yes or no decision and have coded it like this
Char Decision;
Char Positive ;
Char Negative
Char Both;
Char Neither;
Positive = 'y'
Negative = 'n'
Both = 'y' or 'n';
Neither != Both;
Cin>> Decision
If (Decision = 'y')
{Do this}
Else if ( Decision = 'n')
{Do this}
Else while ( Decision != 'y' or 'n')
{Cout<<"type either y or n" << endl;}
I did try using Negative instead of n, Positive instead of y, etc. But that wouldn't work at all so I reverted to this, I can get it to work if y is hit, if n is hit, but if for example j is hit, rather than going onto the loop of unless you hit y or n you're not going anywhere, it instead does the (Decision = y) bit.
Am I going about this completely incorrectly?
Is this the correct way to use chars?
This is the first time I've coded properly in about 1 year + so I am very rusty!
In your if statements you are using = instead of ==
= is for assignments to variables
== is for comparison of equality
if( x = 5 ) will assign the value of 5 to x, the assignment returns the value that was assigned (in this case that would be 5), and any non-zero value is typically evaluated as true. http://www.cplusplus.com/forum/articles/3483/