I wanted to pass an array pointer to a function and show content of that array from that function.I did this in below way but when i run the code the whole program is crashing.Please help me or give me idea how to solve this problem...
int main()
{
int size,i;
cout<<"Please enter the size of the array";
cin>>size;
int *array_=new int [size];
cout<<"Please enter all elements of the array";
for(i=0;i<size;i++){
cin>>array_[i];
}
insertion(&array_,size);
return 0;
}
void insertion(int *array_[],int size){
int i;
for(i=0;i<size;i++){
cout<<*array_[i];
}
}
insertion(&array_,size);. As you want to pass the pointer just change to:insertion(array_,size);insert()is also wrong, should bevoid insertion(int *array_,int size){. Otherwise it expects an array of pointers.