I have no idea how to use new or what it means. I would appreciate it if someone can explain it to me in an easy to understand way since I am a beginner.
If you notice, after I was done using MyArray, I called delete MyArray;
And you just got undefined behavior in your program.
You should never ever use delete for anything allocated with new[], and likewise, never use delete[] for something allocated with new.
Eacch new should be paired with delete and new[] with delete[]