fx_loop_style - fx loop style
Use for() for all of loop.
Use for()
for all of loop. C language provides three loop statements:
for()
, while-do
and do-while
, people are fucking crazy to research
it, use it and read it. Use only for()
statement is unified to stop care
about other loop statements.
// target: finite loop
int array[8] = {1, 2, 3, 4, 5, 6, 7, 8};
for (size_t i = 0; i < 8; ++i) {
}
// target: infinite loop
for (;;) {
}
// target: do some things first then check loop condition
for (bool still_loop = true;;) { // verify loop condition here
// do some things to change
// loop condition here
if (!still_loop) // check loop condition here
break;
}
// target: change loop condition in other statements
for (bool still_loop = true; still_loop;) { // verify loop
// condition here
// change loop
// condition here
}
libfx v0.0.0 © Copyright 2018, Kevin Leptons. Created using Sphinx 1.6.5
Last updated 2018/02/20 06:12