title: How to prevent stack overflow in a game that infinitely loops?
body: <p>I made a Tetris game in c++ command line. It actually works perfectly fine until the stack overflows. I understand what a stack overflow is, but I don't know how to prevent it in a game that is supposed to go on forever. For sake of not sharing 700+ lines of code, I am going to simplify the code into basic functions.</p>
  
  <p>Code:</p>
  
  <pre><code>int main(){
      //Sets position of first block
      //picks random tetris piece for player to control
      updateScreenMain();
  }
  int updateScreenMain(){
      //All code related to drawing screen is here
      //At the end of it, there are several if statments-
      //-that test for if the block hit the ground yet
      // If one of those functions is called, example: reseting the 
      // block to the top of the screen, it will call updateScreenMain() 
      // again
  }
  </code></pre>
  
  <p>Basically, what I want to do is clear the stack memory. I see that when my functions call other functions, they get nested until a stack overflow. How can I prevent this?</p>