AZJIO 155 Posted March 18, 2013 AutoIt3 & С++ My other projects or all Share this post Link to post Share on other sites
JohnOne 1,603 Posted March 18, 2013 ByRef *ByRef & AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
AZJIO 155 Posted March 18, 2013 #include <stdio.h> void swap(int *x, int *y); int main(void) { int i, j; i = 10; j = 20; printf("i, j: %d %d\n", i, j); swap(&i, &j); /* i j */ printf("i, j: %d %d\n", i, j); return 0; } void swap(int *x, int *y) { int temp; temp = *x; /* save x */ *x = *y; /* move y -> x */ *y = temp; /* move x -> y */ } swap(&i, &j) - Call void swap(int *x, int *y) - In the function You cannot use the ByRef in the call My other projects or all Share this post Link to post Share on other sites
JohnOne 1,603 Posted March 19, 2013 That is using pointers. * is symbol for pointer & is symbol for by reference I wont dare go into the difference at my level, but I'm quire sure about this. #include <stdio.h> void swap(int &, int &); int main(void) { int i, j; i = 10; j = 20; printf("i, j: %d %d\n", i, j); swap(i, j); /* i j */ printf("i, j: %d %d\n", i, j); return 0; } void swap(int &x, int &y) { int temp; temp = x; /* save x */ x = y; /* move y -> x */ y = temp; /* move x -> y */ } AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
AZJIO 155 Posted March 19, 2013 Then you are right My other projects or all Share this post Link to post Share on other sites
Richard Robertson 187 Posted March 19, 2013 The difference between & and * is that & passes the address of the variable in the form of a pointer to data. * passes an address to data. It gets especially confusing when both & and * describe the same variable. Share this post Link to post Share on other sites