#include <stdio.h>
void func(int arr[],int xNumOfElem)
{
int j;
for(j=0; j<xNumOfElem; j++)
{
arr[j] = j + arr[j];
printf("%d\t",arr[j]);
}
printf("\n");
}
int main()
{
int *a,k;
a = (int*) malloc(sizeof(int)*10);
for(k = 0; k<10; k++)
{
a[k] = k;
printf("%d\t",a[k]);
}
printf("\n");
func(a,10); //Func call
free(a);
}
Inside the the function "func" who will allocate/deallocate memory for dynamic array "arr".
arr is an function argument.