/*
Initialize an integer array of size 10; pass it to a function ‘arrIncrement’ using a void pointer.
The function should increment all elements of the array by one.
*/
#include <iostream>
void arrIncrement(void * p){
int* a=(int*)p;
for(int i=0;i<10;i++)
(*(a+i))++;
}
int main(void)
{
int a[]={2,5,1,9,7,0,8,-2,55,9};
arrIncrement(a);
for(int i=0;i<10;i++)
std::cout<<*(a+i)<<" ";
std::cout<<std::endl;
return 0;
}
Comments
Leave a comment