Array accessed with pointer - C++ Data Type

C++ examples for Data Type:Array

Description

Array accessed with pointer

Demo Code

#include <iostream>
using namespace std;
int main()//from ww  w . j ava2s  .  c  o m
{
   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;
}

Result


Related Tutorials