1.6. fx_loop_style

1.6.1. NAME

fx_loop_style - fx loop style

1.6.2. SYNOPSIS

Use for() for all of loop.

1.6.3. DESCRIPTION

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.

1.6.4. EXAMPLE 01

// target: finite loop

int array[8] = {1, 2, 3, 4, 5, 6, 7, 8};
for (size_t i = 0; i < 8; ++i) {

}

1.6.5. EXAMPLE 02

// target: infinite loop

for (;;) {

}

1.6.6. EXAMPLE 03

// 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;
}

1.6.7. EXAMPLE 04

// 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