C++ Function Parameter Array passed by pointer
#include <iostream> using namespace std; const int MAX = 5; //number of array elements int main()/*from ww w . j a va 2s .c om*/ { 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 }