avoid repeating a statement

lets say I want to repeat this
1
2
3
4
5
6
7
for(i=0;i<16;i++)
...
...
for(i=0;i<16;i++)
...
for(i=0;i<16;i++)...
for(i=0;i<16;i++)

but typing for(i=0;i<16;i++) every time is kind of lengthy...
isn't there a shortcut???
Solution 1:
    Combine loops into one
Solution 2:
    Move loop with its body inside separate function

Nothing more can be said without knowing context of these loops and what are they doing.
cant we create a variable or something like that???
cant we create a variable or something like that???
Depending on loop context and content.
1
2
3
4
for (int j=0; j<n; ++j) {
    for (i=0; i<16; i++)
        ...
}

Use an editor abbreviation (check the documentation for your editor.)

For instance (vim,allman) :ab forl for( int i=0; i<N; ++i ) <CR>{<CR>
Topic archived. No new replies allowed.