using macros in C to convert multiple arguments into one -


i'm brand new c, , i'm trying following:

i have function move(int x, int y) want able move(center)

i'm trying "#define center x/2, y/2"

what right way this?

move(center)

so want able call move on variable named center? use struct:

struct point {   int x;   int y; }  ...  void move(struct point p) {   // read p.x , p.y }  ...  struct point center; center.x = 20; center.y = 20; move(center); 

i'm not sure intent #define center x/2, y/2 part... did mean #define center width/2, height/2? can center.x = width / 2 , center.y = height / 2.

edit: if can't re-define move try like

void my_move(struct point p) {   move(p.x, p.y); } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -