Array of Pointers 指针数组

#include <iostream>
 
using namespace std;
const int MAX = 8;
 
int main () {
   int  var[MAX] = {10, 100, 200,2,3,5,7,11};
   int *ptr[MAX];
 
   for (int i = 0; i < MAX; i++) {
      ptr[i] = &var[i]; // assign the address of integer.
   }
   
   for (int i = 0; i < MAX; i++) {
      cout << "Value of var[" << i << "] = ";
      cout << *ptr[i] << endl;
   }
   
   return 0;
}

https://www.tutorialspoint.com/cplusplus/cpp_array_of_pointers.htm
posted @ 2019-05-14 10:25  Poission  阅读(218)  评论(0编辑  收藏  举报