Consider the following incorrect code segment. It has two pieces to it: PRINT_THREE_TIMES macro and the code
that uses the macro:
#define PRINT_THREE_TIMES \
printf ("one: %d\n", 1); \
printf ("two: %d\n", 2); \
printf ("three: %d\n", 3); \
if (i == 1)
printf( “Only once: %d\n”, 1 );
else if (i == 2)
printf( “i == 2, we don’t need to print anything here!\n”) ;
else if (i == 3)
PRINT_THREE_TIMES
The code does not quite do what is intended.
show how to do this by changing the macro alone. (You are not allowed to consolidate the three ‘printf’
statements to a single one.)
#define PRINT_THREE_TIMES :



LinkBack URL
About LinkBacks


