You can use the ternary or conditional operator. The basic form is:
condition ? valueIfTrue : valueIfFalse
Example:
const char* x = (SomeFunction() == 0) ? "is null" : "is not null";
When SomeFunction()
returns 0, x
is initialised with "is null
", otherwise
with "is not null
".