I wrote some code:
#include <stdlib.h>
#include <stdio.h>
int a_function(int *a, int a_length, int *returned_address)
{
returned_address=a+a_length-1;
return 0;
}
int main(void)
{
int n=5;
int *a;
int *address=NULL;
a=(int*)malloc(n*sizeof(*a));
a_function(a,n,address);
printf("%p",address);
return 0;
}
The expected result is that the pointer 'address' point to a block of memory at the address of a+4. But the result was that the pointer 'address' still pointed to NULL (the printed result on the screen was like '00000000'). However, when I started debugging, inside 'a_function' the 'returned_address' did point to the memory block at a+4. What am I missing?