As a follow-up question to my previous question here, http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_21782586.html
I'm trying to figure out how to compare multiple bits to check for multiple boolean variables.
As an example, the isalnum function.
Suppose you have:
#define 0x0001 ALPHA
#define 0x0002 DIGIT
#define 0x0003 TRAIT3
#define 0x0004 TRAIT4
charmap['A'] = ALPHA;
Now how would you check if an element of charmap is either alpha or numeric? I tried:
return (charmap['A'] & ALPHA | DIGIT)
But when I combine two traits using the | operator, I always get a greater than 0 value, even if I try it with two traits both of which are incorrect.