Playing with array passing in c. Defining array in function Get_Present_Location() and passing it as a pointer into main where i simply print it. It seems to work except for the last element. Instead of -7 i get 0. Probably there is a stupid mistake on my part but I cannot understand why.
#include <stdio.h>
#include <stdlib.h>
double *Get_Present_Location();
int main(){
double *Present_Point;
Present_Point=Get_Present_Location();
for (int i=0;i<6;i++)
{
printf("Joint[%d] = %f\n",i+1,Present_Point[i]);
}
return 0;
}
double *Get_Present_Location()
{
double point[6]={4,1,5,-3,5,-7}; //Temporary
return &point;
}