I\'m currently trying to figure out a way to break out of a for loop from within a function called in that loop. I\'m aware of the possibility to just have the
for
Just set a global variable and check that on the loop:
#include int leave = 0; void foo (int a) { printf("a: %d", a); leave = 1; } int main(void) { for (int i = 0; i <= 100; i++) { foo(i); if (leave) break; } return 0; }