Use of '#define' for macro definition


#include <iostream.h>
#include <conio.h>
/* macro definition */
/* macro definition if requires more than one program lines as
below, it can be continued on the next line with the help of
a special character used by '#define' which is '\' written
at the end of each  program line of the macro.  */

#define xyz   \
cout<<"\nThe array elements are :\n"; \
for ( i = 0; i < 5; i++ )  \
cout << a[i];

void main()
{
    int a[5], i ;
    clrscr () ;
    for ( i = 0; i < 5; i++ )
        a[i] = i ;
    xyz ;                /* use of call to a macro */
    for ( i = 0; i < 5; i++ )
        a[i] -= 1 ;
    xyz ;                    /* use of call to a macro */
    getch () ;
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|