C++ Array Display array contents using pointer arithmetic
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; void displayArray(int intArray[], int nSize){ cout << "The value of the array is:\n"; int* pArray = intArray; for(int n = 0; n < nSize; n++, pArray++){ cout << n << ": " << *pArray << "\n"; }/* ww w . j a va 2 s. co m*/ cout << endl; } int main(int nNumberofArgs, char* pszArgs[]) { int array[] = {4, 3, 2, 1}; displayArray(array, 4); return 0; }