Passing Pointer to Function
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
/* Passing pointer to a function */
void display(int *a) // a is the pointer to the array.
{
cout<<"Array elements are : " <<endl;
for(int i=0;i<5;i++)
{
cout<< a[i] << "," ;
}
}
int main()
{
int a[5]={10,20,30,40,50};
display(a);
return 0;
}
Output:
Array elements are :
10,20,30,40,50,