In this example, we are creating a pointer to an integer and assign it heap memory. When memory is successfully assigned to the pointer then we can use this pointer as a 1D array and using the square braces “[]” we can access the pointer as like the statically allocated array. Let us see the below Image for better understanding.
Output:
Enter the number of block = 7
pcBuffer[0] = 0
pcBuffer[1] = 1
pcBuffer[2] = 2
pcBuffer[3] = 3
pcBuffer[4] = 4
pcBuffer[5] = 5
pcBuffer[6] = 6
need an explanation for this answer? contact us directly to get an explanation for this answer