I want to write a C function that will print 1 to N one per each line on the stdout where N is a int parameter to the function. The function should not use while, for, do-while
I'd go for using longjmp()
longjmp()
#include #include void do_loop(int n) { int val; jmp_buf env; val = 0; setjmp(env); printf("%d\n", ++val); if (val != n) longjmp(env, 0); } int main() { do_loop(7); return 0; }