Macro Listing

bumsfeld 0 Tallied Votes 277 Views Share

Here is a list of macros I have been using.

// 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

&amp;&amp; stands for the C and = &

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

What bumsfeld means is that &amp;&amp; should be && (and)

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Thanks Dani,
I trust it's you that cleaned up that old &amp;&amp --> should be && problem.

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.