Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 559 Bytes

5.15.md

File metadata and controls

21 lines (16 loc) · 559 Bytes

(a)

int ix;
for (ix = 0; ix != sz; ++ix) { /* ... */ }
//for (int ix = 0; ix != sz; ++ix) { /* ... */ }
// The loop variable is used outside `for` scope, thus should be defined outside.
if (ix != sz)
// ...

(b)

int ix;
//for (ix != sz; ++ix) { /* ... */ }
// When the initialization is unnecessary, a null statement should be used.
for (; ix != sz; ++ix) { /* ... */ }

(c)

for (int ix = 0; ix != sz; ++ix, ++ sz) { /* ... */ }
// The loop will never end.
for (int ix = 0; ix != sz; ++ix) { /* ... */ }