배열 전달 c. Get_Present_Location() 함수에서 배열을 정의하고 포인터를 단순히 main으로 포인터를 전달합니다. 그것은 마지막 요소를 제외하고는 작동하는 것 같습니다. -7 대신에 나는 0을 얻습니다. 아마도 내 부분에 어리석은 실수가 있지만 그 이유를 이해할 수 없습니다.배열 패킹 C
#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;
}