Array of Pointers
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
/* Array of pointers */
int main()
{
int myArray[5] = {1,2,3,4,5};
int *ptr[5];
for (int i = 0; i < 5; i++)
{
ptr[i] = &myArray[i]; // Assign the address of integer.
}
cout << "Values of myArray:"<< endl;
for (int i = 0; i < 5; i++)
{
cout << *ptr[i]<< ",";
}
return 0;
}
Output:
Values of myArray:
1,2,3,4,5,