please dont rip this site

Language Ccpp Cref Examples Macro.c

/ ****************************************************************
 *
 * Purpose: To demonstrate macros
 * Author:  M.J. Leslie
 * Date:    17-Oct-94
 *
 ****************************************************************/

#define SQUARE(x) ( (x)*(x) )

main()
{
  int value=3;

  printf("%d \n", SQUARE(value));
}
/****************************************************************
 *
 * answer will be 9
 *
 ****************************************************************/

	-------------------------------------------------


// Another common macro to compute the absolute value.
#define absolute_value( x ) ( ((x) < 0) ? -(x) : (x) )

// and here is a sample useage...
int x = -1;
while( absolute_value( x ) ) {
// ...
  }       


	-------------------------------------------------

//a general purpose incrementing "for" loop
#define count_up( v, low, high ) \
	for( (v) = (low); (v) <= (high); (v)++ )          

//prints out the integers 1 through 20:
int i;
count_up( i, 1, 20 ) {
	printf( "i is %d\n", i );
	}  


file: /Techref/language/ccpp/Cref/EXAMPLES/macro.c, 1KB, , updated: 2006/8/3 11:55, local time: 2024/12/2 09:08,
TOP NEW HELP FIND: 
52.14.252.16:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/Techref/language/ccpp/Cref/EXAMPLES/macro.c"> language ccpp Cref EXAMPLES macro</A>

Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .