Agnius Vasiliauskas Agnius Vasiliauskas - 1 year ago 173
C Question

Use of null statement in C

What are typical uses of null statement


in C ?

(I know that it is basically used to skip expression where it is expected by the compiler, but here I'm interested only in real-world examples of such use cases...)


Answer Source

It's typically the side-effect of a code block that was stripped by the preprocessor, like

    #define ASSERT(_x) Assert(_x)
    #define ASSERT(_x)

ASSERT(test);    // Results in null statement in non-debug builds

That, or in loops where your condition already contains whatever needs to be done in each iteration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download