I tried to figure out how far I can get to C ++ recursion. I wrote this function
long recurse( long level ) {
std::cout << level << std::endl;
return recurse( ++level ) * 12
}
And I called it passing 0 as the first value. The last number he printed was 349411, then he printed Segmentation faultand stopped. I suppose she ran out of memory, but the same function called with the same value prints 499982 before throwing an error stack overflowin Lua, and I would be surprised if Lua functions had less weight in memory than C ++ functions.
So what is the maximum stack level a C ++ program can get before stopping it?
Is it really “as long as it has no memory”, or is there a fixed limit?
Also why is it typing Segmentation fault?
Isn't this message printed only when accessing memory in an extraneous way?
source
share