Unhandled exception at 0x771CC7C9 (ntdll.dll)
<p><strong>I have the following code in which an array is dynamically declared in a function. The following program compiles perfectly in Visual Studio 2013. However, during runtime the code breaks during printing the array, with the following error code:</strong></p>

<p><em>Critical error detected c0000374
WaveEquation1D.exe has triggered a breakpoint.
First-chance exception at 0x771CC7C9 (ntdll.dll) in WaveEquation1D.exe: 0xC0000374: A heap has been corrupted (parameters: 0x771F8890).</em></p>

<p><em>Unhandled exception at 0x771CC7C9 (ntdll.dll) in WaveEquation1D.exe: 0xC0000374: A heap has been corrupted (parameters: 0x771F8890).</em></p>

<p><strong>What is going on? Please help</strong></p>

<pre><code>#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;vector&gt;
using namespace std;

int solver(double i, double v, double c, double L, int Nx, double C1, double t);

int solver(double i, double v, double c, double L, int Nx, double C1, double t)
{
    double *msh = new double(Nx);
    double delta = L / Nx;

    int count = 0;
    for (int i = 0; i &lt;= Nx; i++)
    {
        msh[i] = 0.0;
    }

    for (int i = 0; i &lt;= Nx; i++)
    {
        msh[i] += delta*count;
        count++;
    }


    for (int i = 0; i &lt;= Nx; i++)
    {
        cout &lt;&lt; msh[i] &lt;&lt;endl;
    }
    delete[] msh;



//  

    return 0;
}



int main()
{
    cout &lt;&lt; "Hello"&lt;&lt;endl;
    int size;

    int j;
    j = solver(1, 0, 0, 20.0, 20, 0, 1);
    _getch();
    return 0;
}
</code></pre>