C++ Pointer Array accessed with pointer

Description

C++ Pointer Array accessed with pointer

#include <iostream>
using namespace std;
int main()/*  w  w  w  .j  a v a  2  s  .c om*/
{
   int intarray[] = { 31, 54, 77, 52, 93 }; //array
   int* ptrint;                             //pointer to int
   ptrint = intarray;                       //points to intarray
   for(int j=0; j<5; j++)                   //for each element,
      cout << *(ptrint++) << endl;          //print value
   return 0;
}



PreviousNext

Related