Access next array element by add one to array pointer, *(arrayName + i) - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Access next array element by add one to array pointer, *(arrayName + i)

Demo Code

#include <iostream>
using namespace std;
int main()/*  w w  w  .j a  v  a2s.  c  om*/
{
   const int ARRAYSIZE = 5;
   int i, grade[ARRAYSIZE] = {98, 87, 92, 79, 85};
   for (i = 0; i < ARRAYSIZE; i++)
      cout << "\nElement " << i << " is " << *(grade + i);
   cout << endl;
   return 0;
}

Result


Related Tutorials