title: Debug Assertion Failed. BIG_ALLOCATION_ALLIGNMENT
body: <p>I'm trying to take user inputted notes and store them in an array. The validation works fine but when I input the last value in the loop I get:</p>
  
  <pre><code>Debug Assertion Failed!
  Expression: "(_Ptr_user &amp; (_BIG_ALLOCATION_ALIGNMENT - 1))==0"&amp;&amp;0
  An invalid parameter was passed to a function that considers invalid parameters fatal.
  </code></pre>
  
  <p>I'm struggling to understand where the issue is and how I can fix it.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  typedef string noteName;
  
  noteName getNoteName(int i)
  {
      bool flag = true;
      noteName Namein;
  
      do
      {
          cout &lt;&lt; "Please enter note name no. " &lt;&lt; i + 1 &lt;&lt; ": ";
          cin &gt;&gt; Namein;
          cout &lt;&lt; "------------------------------------\n";
  
          if (Namein.length() &gt; 3 || Namein.length() &lt; 2)
          {
              cout &lt;&lt; "Sorry, a note name must be 2 or 3 characters long. Please try again.\n";
              flag = false;
          }
          else if (Namein.length() == 3 &amp;&amp; Namein[1] != '#')
          {
              cout &lt;&lt; "Sorry, the second character of a sharp note name must be #. Please try again.\n";
              flag = false;
          }
          else if ((Namein[0] &lt; 'a' || Namein[0] &gt; 'g') &amp;&amp; (Namein[0] &lt; 'A' || Namein[0] &gt; 'G'))
          {
              cout &lt;&lt; "Sorry, the first character of a note name must be a letter between A and G. Please try again.\n";
              flag = false;
          }
          else if (isdigit(Namein.back()) == false)
          {
              cout &lt;&lt; "Sorry, the last character of a note name must be a number. Please try again.\n";
              flag = false;
          }
          else
          {
              flag = true;
          }
      } while (flag == false);
  
      return Namein;
  }
  
  int main()
  {
     const int numNotes = 4;
  
      noteName NoteNames[numNotes];
  
      cout &lt;&lt; "Hello\n";
  
      for (int i = 0; i &lt;= numNotes; i++)
      {
          NoteNames[i] = getNoteName(i);
      }
  
      cout &lt;&lt; "Thank you, the note names and lengths you entered were: \n\n";
  
      for (int i = 0; i &lt;= numNotes; i++)
      {
          cout &lt;&lt; i &lt;&lt; ". " &lt;&lt; NoteNames[i] &lt;&lt; "\n";
      }
  
      cout &lt;&lt; "Done!";
  
      return 0;
  }
  </code></pre>
  
  <p>I want to say it's something to do with <code>getNoteName()</code> having a <code>string</code> return type as I haven't had this issue with any of my other functions that return <code>int</code>.</p>