This program demonstrates the use of an array of pointers in C++.
Note that the use of an array of pointers can be helpful in certain situations, such as when dealing with arrays of arrays or arrays of strings, as it allows for more flexible memory management.
#include<iostream> using namespace std; int main() { int ptr1[5]; int *ptr2[5]; std::cout<<"Enter five numbers :"<<std::endl; for(int i=0;i<5;i++) { std::cin>>ptr1[i]; } for(int i=0;i<5;i++) { ptr2[i]=&ptr1[i]; } std::cout<<"The values are"<<std::endl; for(int i=0;i<5;i++) { std::cout<<*ptr2[i]<<std::endl; } return 0; }To download raw file Click Here
Enter five numbers :34 12 31 54 23 The values are 34 12 31 54 23
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions