OR not working with char

Write your question here.
when i try to put or in between characters the whole while statement doesn't work.. why? what do i have to change ?
 
  while(choice!='C' || 'c')
while( choice != 'C' && choice != 'c' )


or you could use
1
2
3
#include <cctype>
...
  while( tolower( choice) != 'c' )
that might work for that part only .. bcuz i have a menu and options are A or a (higher case OR lower case).. so the user has to enter one char, if i use '&&' the option won't activate .. when i try to use OR it won't work :(
Operator precedence
1
2
3
choice!='C' || 'c'
// is same as
( choice != 'C' ) || ( 'c' )

In other words, the condition is true
when choice is not C
but also when choice is C, because c is always true
Always true.

( choice != 'C' ) || ( choice != 'c' )
would be false, if choice could be C and c simultaneously.
Can't. This condition is always true.

( choice != 'C' ) && ( choice != 'c' )
This is false if choice is C or choice is c.

choice == 'C' || choice == 'c'
This is true if choice is C or choice is c.

!( choice == 'C' || choice == 'c' )
This is false if choice is C or choice is c.
thank you
Topic archived. No new replies allowed.