int *mA(int x){
int *arr[x], i = 0;
while(i<x){
arr[x]=i;
printf("%d ", arr[x]);
i++;
}return arr;
}
void fA(int *arr, int x){
int j=0;
while(j<x){
printf("%d ", arr[x]);
j++;
}
mA
is the function which creates array with the input length. If user inputs 5 as length then the array will be assigned as 1 2 3 4 5. The reason why I have put printf("%d ", arr[x]);
in mA
function is because I wanted to test whether it successfully assign 0 into array or not and as a result, it worked. However in fA
, it shows nothing. I am using call by reference method but due to my limited knowledge I can't solve this error. if mA
function successfully assigned 0 into array then fA
function should be able to read and display the result, but what is the problem here?