First thing to understand is what happens during the preprocessor phase and what the code looks like afterwards. So lets take a look:
Code:
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)
printf ("one: %d\n", 1);
printf ("two: %d\n", 2);
printf ("three: %d\n", 3);
Now if you can't see the problem yet lets add proper indentation
Code:
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)
printf ("one: %d\n", 1);
printf ("two: %d\n", 2);
printf ("three: %d\n", 3);
Wait thats not what you wanted. You wanted this:
Code:
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)
{
printf ("one: %d\n", 1);
printf ("two: %d\n", 2);
printf ("three: %d\n", 3);
}
So can you guess how you should change the macro?