/******************************************************************************
Welcome to code of Lập trình - Điện tử
Series: C++
Author: Nghĩa Taarabt
*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
int *arr = new int[5];
int idx = 0;
// access to heap memory by array
for (idx = 0; idx < 5; idx++)
{
arr[idx] = idx;
}
// access to heap memory by pointer
for (idx = 0; idx < 5; idx++)
{
cout << *(arr+idx) << " ";
}
}