The Null Statement

Objective-C permits you to place a solitary semicolon wherever a normal program statement can appear. The effect of such a statement, known as the null statement, is that nothing is done. This might seem quite useless, but programmers often do this in while, for, and do statements. For example, the purpose of the following statement is to store all the characters read in from standard input (your terminal, by default) in the character array that text points to until a newline character is encountered. This statement uses the library routine getchar, which reads and returns a single character at a time from standard input:

while ( (*text++ = getchar ()) != '' )  ;

All the operations are performed inside the looping conditions ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.