How would I define multiple values of the same type in an array using #define ?
For instance, I would like
#define DIGIT 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39
#define QUOTE 0x22 | 0x27
ETC...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, the term array in C and C++ refers to a number of variables of the same type, all side by side in memory. If you really wanted an array, then you can use:
Of course, there’s nothing to stop you putting part of this in a preprocessor macro, but no obvious point either, and macros are best avoided as conflicting and unintended substitutions aren’t always handled well by the compiler:
If your intension it to check whether a particular character is one of the listed characters, then you can do it in many ways: