简体   繁体   中英

Change point coordinates

I need help solving this problem in my mind so if anyone had a similar problem it would help me.

We have one point in the function main , which represents the center of the coordinate system with a certain name O(0,0) , how to use the function function to change that point in A(1,2) ?

Here's my code:

struct Point {char m;float x, y;};
void function(struct Point t, char s,float array[2])
{
   t.m=s;
   t.x=array[0];
   t.y=array[1];

}
int main()
{
   float array[]={1,2};
   struct Point t1={'O',0,0};;
   function(t1,'A',array);
   printf("%c(%.2f,%.2f)",t1.m,t1.x,t1.y);
   return 0;
}

Note the function function must have a prototype function(struct Point t,char s,float array[2]);

Thanks in advance!

Best regards!

It cannot be done. The provided function prototype provides no way to return any modified values to its callers other than floats.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM