C++ Pointer Increments a pointer through an integer array.

Description

C++ Pointer Increments a pointer through an integer array.

#include <iostream>
using namespace std;
void main()//from  ww w .  j  ava 2s  .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;
}



PreviousNext

Related