Increments a pointer through an integer array. - C++ Data Type

C++ examples for Data Type:Array Pointer

Description

Increments a pointer through an integer array.

Demo Code

#include <iostream>
using namespace std;
void main()/*from  w  w  w. j a  v a  2 s.c o m*/
{
   int iara[] = {10,20,30,40,50};
   int *ip = iara;              // The pointer points to The start of the array.
   cout << *ip << "\n";
   ip++;                           // Two are actually added.
   cout << *ip << "\n";
   ip++;                           // Two are actually added.
   cout << *ip << "\n";
   ip++;                           // Two are actually added.
   cout << *ip << "\n";
   ip++;                           // Two are actually added.
   cout << *ip << "\n\n";
   cout << "The integer size is " << sizeof(int);
   cout << " bytes on this machine \n\n";
   return;
}

Result


Related Tutorials