title: How to end the program from a function which is called in another function (C++)
body: <p>I have a loop of functions that I called like the code I wrote below and I want at some point to end the program.The problem is that I don't want to use exit function because I have data allocated dynamic also I could use an if in every function and exit one by one but I think will make the code a lot harder to understand and I have more than 3 functions like this.</p>
  
  <pre><code>void c()
  {
       //code
       //I want to exit the program
  }
  
  void b()
  {
       c();
       //code
  }
  
  void a()
  {
       b();
       //code
  }
  
  int main()
  {
       a();
       return 0;
  }
  </code></pre>
  
  <p>Thanks for the help.</p>