3 ms·
Just because I haven't seen it mentioned yet, here's a solution using gcc's computed goto feature: #include <cstdio> int main(int argc, char** argv) {
by vilya 16y ago
Just because I haven't seen it mentioned yet, here's a solution using gcc's computed goto feature:
#include <cstdio>
int main(int argc, char** argv) {
void* labels[2] = { &&doing, &&done };
int i = 1;
doing:
printf("%d\n", i++);
goto *labels[i / 1001];
done:
return 0;
}
Still consider goto harmful? (Well yeah, so do I generally. But hey...)