Why some people declare an cycle's iterator out of them? Like this:
int do_work(const int iqt) {
register int i;
for (i = 0; i < iqt; i++) {
/* very busy work ;d */
}
return 0;
}
Is it a good practice?
And another questions: is it profitable to mark every iterator with register keyword?
There are two things here:
"Declaring the variable inside the loop" feature was added in
C99, any legacy code before that would be bound to declare the variables before the loop. For the legacy code, it was more of a requirement than a practice. However, postC99era, can have it either way. Some people (including me) find it useful to declare variables closest to their usage.The
registerkeyword is not a guarantee, it's a hint to the compiler. Compilers are free to ignore it. QuotingC11, chapter §6.7.1