Here is a list of macros I have been using.
Macro Listing
// a short list of popular macro defines
// macros to get high and low byte of an integer x
#define HIBYTE(x) ((unsigned int)(x) >> 8)
#define LOWBYTE(x) ((unsigned char)(x))
// years ending with 00 have to divisible by 400 to be leap year
#define ISLEAPYEAR(year) ((!(year % 4) && (year % 100)) || (!(year % 400) && (year % 1000)))
// RGB macro red, green, blue are bytes 0 to 255
#define RGB(r,g,b) ((DWORD)(((BYTE)(r)|((WORD)(g) << 8))|(((DWORD)(BYTE)(b)) << 16)))
// macro to swap two arguments of a specified type (here int)
#define SWAP(a,b) { int t; t=a; a=b; b=t; }
// DOS console mode only
#define clrscr() system("CLS")
// macros for arrays
#define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x)))
#define NELEM(x) (sizeof(x)/sizeof(x[0]))
bumsfeld 413 Nearly a Posting Virtuoso
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.