Hey!

I am fairly new to C so forgive me if things arent extremely clear

but basically I'm trying to figure out the full scope of what I can and cant do.

I have a program that takes the longitude and latitude in degrees and then

sends it to a function which then calculates its rectangular co-ordinates ..x,y,z

the problems lies here. im sending two double values lat and longitude to the function.. and i want to return 3 double values x,y,z i know i could write it to a data file then retrieve it outside the function etc.. but i would like to know how to do this with pointers and arrays... if it can be done at all

here is the main function... the programer defined function is "rectangle"

and the rectangle function isCode:#include "stdafx.h" #include <stdio.h> #include <math.h> #define PI 3.14159265 int main(void) { double lat1,*lat[4], long1, lat2, long2, x1, y1, z1, x2, y2, z2, theta, rho, lengtha, lengthb; double gc_distance(double x); double rectangle(double *str); double retrive[4]; double *ptr1; double ptr2[4]; ptr1=retrive; printf("enter latitude and longitude of the first city\n"); scanf("%f%f",&lat1,&long1); retrive[1]=lat1; retrive[2]=lat2; ptr2 = rectangle(ptr1); printf("\n\n%.2f %.2f %.2f\n",ptr2[1],ptr2[2],ptr2[3]); printf("enter latitude and longitude of the second city\n"); scanf("%f%f",&lat2,&long2); return 0; }

Code:double rectangle(double *str) { double phi, theta, rho, x1, y1, z1, x2, y2, z2; double test[4]; double *ptr; ptr = test; phi= (90 - str[1])*(PI/180); theta=(360 - str[2])*(PI/180); rho= 3960; x1 = rho*sin(phi)*cos(theta); y1 = rho*sin(phi)*sin(theta); z1 = rho*cos(phi); printf("%.2f %.2f %.2f\n\n", x1,y1,z1); test[1] = x1; test[2] = y1; test[3] = z1; printf("%.2f %.2f %.2f\n\n", str[1],str[2],str[3]); return (*ptr); }

the way it is set up right now is not working... it wont let me assign ptr2 = rectangle(ptr1) it says expression must be modifieable value...

any help would be much appreciated.. thanks