Problem deleting dynamic array
So I dynamically allocated an array in a simple function and when I tried to free up the memory at the end of the function I got some kind of error during run time. When I removed the 'delete' statement the program ran fine. Please advice.
Code:
#include <windows.h>
#include <iostream>
using namespace std;
void drawstuff(char array[]);
int main()
{
char *b = "I am Peter";
drawstuff(b);
}
void drawstuff(char array[]) {
char *a = new char[10];
for (int i = 0; i < 11; i++)
a[i] = array[i];
std::cout << a << endl;
delete []a;
}