The code below is ok with return n <= 100 && (printf("%d\n", n), print(n+1)) || 0;
but gives error for return n <= 1000 && (printf("%d\n", n), print(n+1)) || 0;
#include <stdio.h>
int print(int n)
{
return n <= 1000 && (printf("%d\n", n), print(n+1)) || 0;
}
int main(void)
{
print(1);
return 0;
}
This code has following error : Divide error expectation and Resumable processor fault
I'm using Borland Turbo c++ 4.5 on windows 7.
How to fix it and also suggest a good C(specifically) IDE. I think eclipse c/c++ is a good option but confused.
Looks like a simple stack overflow caused by the recursion depth. Your options: