| |||
| Home > RealView Debugger Keywords > Alphabetical keyword reference > if-else | |||
Provides a way to specify an alternative statement to execute if the if statement evaluates to False.
if (expression) /* If expression is True */ {statement_1; /* execute statement_1 */ [statement;]... /* and these additional statements */ }else /* If expression is False */ {statement_2; /* execute statement_2 */ [statement;]... /* and these additional statements */ }
The if-else statement provides a way to specify
an alternative statement to execute if the if statement
evaluates to False. If the expression evaluates to True, that is
nonzero, and
any following statements are executed, but statement_1 and
any following statements are not executed. If the expression evaluates
to False, that is zero, statement_2 and
any following statements are executed, but statement_2 and
any following statements are not executed. If you have more than
one statement in the if section or in the else section
these must be enclosed in curly braces (statement_1{}).
This example shows how to use if-else in a macro:
if (n==0) strcpy(number,"zero"); else strcpy(number,"nonzero");
if.