Preprocessor Directives 359
{
int k;
# undef wait () getche () ;
clrscr();
for (k=l;k<=5;k++)
printf ("% d t",k);
wait;
Explanation In the above program w ait ( ) is defined in place of getche ( ) . In the program
#undef d ire c t iv e undefines the same macro. Hence, the compiler flags an error message
"undefined symbol 'w a it ' in function main."
11.4 TOKEN PASTING AND STRINGIZING OPERATORS
Stringizing operation In this operation macro argument is converted to string. The sign # carries
the operation. It is placed before the argument.
11.6 Write a program to carry out stringizing operation.
# include <stdio.h>
# include <conio.h>
# define say(m) prin tf (#m)
void main ()
{
clrscr ();
say (Hello);
}
OUTPUT:
Hello
Explanation In the above program after conversion the statement say (Hello) is treated as p rin tf
( "H e llo") . It is not essential to enclose the text in quotation marks in the stringizing operator.
11.7 Write a program to carry stringizing operation and macro arguments.
# include <stdio.h>
# include <canio. h>
# define DOUBLE(x) p rintf ("Double of *#x* %dn'r,x+2)
# define TRIPLE(x) prin tf ("Triple of *#x* - %d *,x*3)
void main ()
{
int m;
clrscr ();
printf ("Enter a number:");
scanf ("% d M m );
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.220.92