skip execution of some statements

Mar 26, 2012 at 12:20pm
Is there any way to enforce c++ compiler to skip some statements on the basis of a condition ?
For Example :

if(i>10)
{
//do not execute any printf statements inside this if block
}
Mar 26, 2012 at 12:43pm
Do you actually mean the compiler - the thing that turns your text source code into a program? Or do you mean that you want something to happen when the program is run?

1
2
3
4
if(i>10)
{
   printf ("Only show me if i is greater than ten");
} 
Last edited on Mar 26, 2012 at 12:45pm
Mar 26, 2012 at 1:02pm
closed account (zb0S216C)
Obviously you don't understand control branching. A if block will only be executed if the condition is true. Otherwise, the block (or statement) following the condition is ignored.

Wazzak
Topic archived. No new replies allowed.