I have read that to return a pointer from a function to another function, the function that passes the pointer must be a pointer function. I mean for instance if the name of function is int Add
it must be int *Add
but when I test it, it seems like either way works just fine ? Is that a non mandatory rule ?
#include <stdio.h>
int *random_func(){ // if remove * and recompile it, still works fine.
int arr[2] = {12,13};
int *point = (int*) malloc(2*sizeof(int));
point= arr;
return point;
}
main(){
int *ptr;
ptr=random_func();
printf("%d %d ",*(ptr), *(ptr+1));
return 0;
}