doesn't seem to work. i've printed each one out and even though they show the same character the if statement doesn't evaluate as true. am i doing something wrong or can i not evaluate three variables, and need to do something like
The problem here is that (x == y == z) is interpreted as ((x == y) == z) which effectively compares first two chars, which gives a boolean result and then compares that result to char z.This test might even pass, but it's definitely not you want.
If you want to test whether three variables are equal - you may write
if( x == y && x == z )
//Or
if( x == y && y == z )
//a function for this
template<typename T>
bool ifEqual(T a, T b, T c)
{
return (a==b&&b==c);
}
...
if( ifEqual<char>(x,y,z) )