title: Unhandled exception in C++ program
body: <p>I'm trying to answer this question from my C++ book that says:　There are n people in a room, where n is an integer greater than or equal to 2. Each person shakes hands once with every other person. What is the total number of handshakes in the room? Write a recursive function to solve this problem.
  I've written a program, but nothing is being outputted from the function. I'm pretty sure my stuff inside the handshake function is correct, but nothing is being outputted by the function inside the main function. It keeps giving me an error: 
  Unhandled exception at 0x00c01639 in Problem2.exe: 0xC00000FD: Stack overflow.
  Thank you for your help in advance!</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  
  using namespace std;
  
  int handshake(int n);
  
  int main()
  {
      int i, n;
  
  cout&lt;&lt;"How many people are in the room? ";
  cin&gt;&gt;i;
  
  
  for (n = 1; n = i; n++)
  {
      handshake(n);
  }
  
  cout&lt;&lt;"There are "&lt;&lt;handshake(n)&lt;&lt;" in the room"&lt;&lt;endl;
  
  getche();
  return 0;
  }
  
  int handshake(int n)
  {
      if (n == 1)
      {
              return 0;
          }
      else if (n == 2)
      {
                          return 1;
  }
  else
  {
      return (handshake(n) + (n - 1));
  }
  }
  </code></pre>