Go to the first, previous, next, last section, table of contents.

size_t

All objects (blocks of memory, etc) should be measured in terms of a size_t type. Therefore any iterations (e.g. for(i=0; i<N; i++)) should also use an index of type size_t. If you need to write a descending loop you have to be careful because size_t is unsigned, so instead of

for (i = N - 1; i >= 0; i--) { ... }

use something like

for (i = N; i > 0 && i--;) { ... }

to avoid problems with wrap-around at i=0.

If you really want to avoid confusion use a separate variable to invert the loop order,

for (i = 0; i < N; i++) { j = N - i; ... }

Go to the first, previous, next, last section, table of contents.