JohnOne Posted March 18, 2013 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.
AZJIO Posted March 18, 2013 Author 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
JohnOne Posted March 19, 2013 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.
Richard Robertson Posted March 19, 2013 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now