A statement may be empty. This means that the body of the for loop (or any other loop)
may also be empty. You can use this fact to improve the efficiency of certain algorithms
and to create time delay loops.
Removing spaces from an input stream is a common programming task. For
example, a database program may allow a query such as "show all balances less than
400." The database needs to have each word fed to it separately, without leading
spaces. That is, the database input processor recognizes "show" but not " show". The
following loop shows one way to accomplish this. It advances past leading spaces in
the string pointed to by str.
for( ; *str == ' '; str++) ;
As you can see, this loop has no body—and no need for one either.
Time delay loops are often used in programs. The following code shows how to
create one by using for:
for(t=0; t<SOME_VALUE; t++) ;
may also be empty. You can use this fact to improve the efficiency of certain algorithms
and to create time delay loops.
Removing spaces from an input stream is a common programming task. For
example, a database program may allow a query such as "show all balances less than
400." The database needs to have each word fed to it separately, without leading
spaces. That is, the database input processor recognizes "show" but not " show". The
following loop shows one way to accomplish this. It advances past leading spaces in
the string pointed to by str.
for( ; *str == ' '; str++) ;
As you can see, this loop has no body—and no need for one either.
Time delay loops are often used in programs. The following code shows how to
create one by using for:
for(t=0; t<SOME_VALUE; t++) ;
No comments:
Post a Comment