F
Francesco S. Carta
Hi there,
here is a very simple program that uses a for loop in an uncommon way
(uncommon for me):
-------
#include <iostream>
int i;
void init() {
i = 0;
}
bool check() {
return i < 10;
}
void change() {
++i;
}
void print() {
std::cout << i << std::endl;
}
int main() {
for (init(); check(); change()) print();
}
-------
The request is: could you point out some real life example where you
have found it useful (or maybe even necessary) to use the for loop in
such an indirect way?
Please forgive me for such a candid question, I'm an hobbyist: just out
of curiosity ;-)
Cheers,
Francesco
here is a very simple program that uses a for loop in an uncommon way
(uncommon for me):
-------
#include <iostream>
int i;
void init() {
i = 0;
}
bool check() {
return i < 10;
}
void change() {
++i;
}
void print() {
std::cout << i << std::endl;
}
int main() {
for (init(); check(); change()) print();
}
-------
The request is: could you point out some real life example where you
have found it useful (or maybe even necessary) to use the for loop in
such an indirect way?
Please forgive me for such a candid question, I'm an hobbyist: just out
of curiosity ;-)
Cheers,
Francesco