LearnCPP icon indicating copy to clipboard operation
LearnCPP copied to clipboard

Illustrating the Relationship between Array and Pointers

Open 11gurmeet11 opened this issue 1 year ago • 2 comments

#include < iostream >

using namespace std;

int main() { // Defining an array int arr[ ] = { 1, 2, 3, 4 };

// Define a pointer
int* ptr = arr;

// Printing address of the arrary using array name
cout << "Memory address of arr: " << &arr << endl;

// Printing address of the array using ptr
cout << "Memory address of arr: " << ptr << endl;

return 0;

}

11gurmeet11 avatar Aug 27 '24 15:08 11gurmeet11