   stack overflow: How to prevent it
  What can one do to prevent a stack overflow on recursive functions. I dont want to convert it to an iterative function. Is there maybe a way to tell windows to reserve more meory, maybe as virtual memory? I also heard one could manage memory explicitely for the recursive function. But how?Any tips on these are highly appreciated. And I''m looking for a fast to implement solution.-CProgrammer 
  Not sure about how to increase the stack space, but first make sure the function isn''t recursing infinitely.If not, figure out what''s taking up the most memory, and dynamically allocate what you need up front. ;  I think that the default stack space allocated for your program is a compiler option. Another method could be to limit the number of times that the function gets recursed, although that may not be feasible in your case. ;  failing that, you could always set up your own stackspace before going into your recursive function, make it a few meg big and then restore the stack when it exits... ofcourse, that could be a tad over the top ;  Another possible solution is to see if your compiler supports tail-recursion (I THINK gcc does but don''t quote me on that), and if it does, write the function as tail recursive. ;  gcc doesn''t have C/C++ tail recursion in any of it''s stable branches yet. Limited C++ tail recursion is currently being tested in what will become the 3.4 release.If you''re worried about out of control recursion, then one approach is to add an additional parameter to each call that indicates it''s call depth. If the call depth exceeds a certain threshold, throw an exception or something. ;  Well since the amount of recursion depends on the user input, I''d prefer it if theres no limit or at least have a much higher limit. Changing the options of the stack space sounds like a great solution, although I dont know how. Im using visual c++6-CProgrammer ;  It''s a linker option, look for a stack reserve property in the project settings. ;  Changing the stack size really isn''t the "right" solution to this problem, IMO, but try looking under Project settings, Linker options. Maybe something about "system" or something. Look around in there. That''s where it is in .NET 2003.What does this function do anyway? ;  stack allocations: reserve: But is it in MB or bytes...?-CProgrammer 