C++ Pointer Array passed by pointer
#include <iostream> using namespace std; const int MAX = 5; //number of array elements int main()//from w w w .j a v a 2 s . c o m { void centimize(double*); //prototype double varray[MAX] = { 10.0, 43.1, 95.9, 59.7, 87.3 }; centimize(varray); //change elements of varray to cm for(int j=0; j<MAX; j++) //display new array values cout << "varray[" << j << "]=" << varray[j] << " centimeters" << endl; return 0; } void centimize(double* ptrd) { for(int j=0; j<MAX; j++) *ptrd++ *= 2.54; //ptrd points to elements of varray }