6824 ufalloc () { register i; for (i=0; i<NOFILE; i++) if (u.u_ofile[i]==NULL) { u.u_ar0[R0] = i; return (i); } u.u_error = EMFILE; return (-1); }
This example introduces the “for” statement, which has a very general syntax making it both powerful and compact.
The structure of the “for” statement is adequately described on page 10 of the “C Tutorial”, and that description is not repeated here.
The Algol equivalent of the above “for” statement would be
for i:=1 step 1 until NOFILE-1 do
The power of the “for” statement in “C” derives from the great freedom the programmer has in choosing what to include between the parentheses. Certainly there is nothing which restricts the calculations to integers, as the next example will demonstrate.