title: How does manipulation of a char array cause a stack overflow?
body: <p>If there is a blatantly obvious flaw, I'm sorry. I'm fairly new to memory, so I have some understanding on how stack overflows work and as far as I know, nothing I'm doing should cause a stack overflow. All I'm doing is changing the character in a string. </p>
  
  <p>I know arrays are pointers, but would changing the value cause a stack overflow?</p>
  
  <p>Here is the concerning function:</p>
  
  <pre><code>char base[] = "aaaaa";
  void changeLetters(int position) { // Stack overflow happens around here
      if (base[position] != 'z') {
          base[position]++;
      }
  
      // When I include a cout here, I also get a stack overflow
  
      if (position == 4 &amp;&amp; base[position] != 'z') {
          changeLetters(position);
      }
      else if (base[position] == 'z' &amp;&amp; position != 0) {
          base[position] = 'a';
          changeLetters(position - 1);
      }
      else if (position &lt; 4) {
          changeLetters(position + 1);
      }
  }
  </code></pre>
  
  <p>When not having <code>std::cout</code>, I get the </p>
  
  <blockquote>
    <p>Unhandled exception at 0x767C3210 (KernelBase.dll) in passwordCracker.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x01002FFC).</p>
  </blockquote>
  
  <p>Otherwise</p>
  
  <blockquote>
    <p>Unhandled exception at 0x009C38B9 in passwordCracker.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x006D2F8C).</p>
  </blockquote>
  
  <p>Edit:
  The function is called in the main loop. The value passed is the length of the string (4), and it works its way through. One odd thing I didn't mention is that it works perfectly if I cycle through a smaller amount of letters (a, b, c, d) but I only recieve a stack overflow if I have it cycle through the alphabet.</p>