title: Stack overflow (parameters: 0x00000001, 0x00442FF8)
body: <p>Algorithm checks if both variables "a" and "x" are prime numbers.If yes, it simply announce that these are prime.Need 50 of them, when it comes to 6th position program shows an error: </p>
  
  <blockquote>
    <p>Exception thrown at 0x00D02509 in ConsoleApplication3.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x002D2F5C). Unhandled exception at 0x00D02509 in ConsoleApplication3.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x002D2F5C).</p>
  </blockquote>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  
  int CheckIfPrime(long int n)
  {
      if (n&lt;2) return 0;
      for (int i = 2; i*i &lt;= n; i++)
          if (n%i == 0) return 0;
      return 1;
  }
  
  int pow(int ap, int nt)
  {
      if (nt == 0)
          return 1;
      else
          return ap *= pow(ap, --nt);
  }
  
  void CountA(int *aValue, int x)
  {
      *aValue = (pow(2, x) - 1);
  }
  
  int main()
  {
      int x = 1;
      int a = 0;
      int *aPointer = &amp;a;
      for (int i = 0; i &lt;= 50;)
      {
          x++;
          if (CheckIfPrime(x))
          {
              CountA(aPointer, x);
              if (CheckIfPrime(a))
              {
                  cout &lt;&lt; i &lt;&lt; ". X = " &lt;&lt; x &lt;&lt; " a = " &lt;&lt; a  &lt;&lt; " are prime " &lt;&lt; endl;
                      i++;
              }
          }
          else
          {
              cout &lt;&lt; "";
          }
      }
      getchar();
      return 0;
  }
  </code></pre>