c++ allocate memory code example
Example 1: c++ delet from memory
// Delete pointer
int* ptr1 = new int;
delete ptr1;
// Delete array
int* array = new int[10];
delete[] array;
Example 2: c++ delete dynamically allocated array
int length = 69;
int * numbers = new int[length];
delete[] numbers;
Example 3: cpp malloc
int alloc_size = 10;
int* buffer = (int*) malloc (alloc_size);
//Allocate memory block which can fit 10 integers