AZJIO Posted March 18, 2013 Share Posted March 18, 2013 AutoIt3 & С++ My other projects or all Link to comment Share on other sites More sharing options...
JohnOne Posted March 18, 2013 Share 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. Link to comment Share on other sites More sharing options...
AZJIO Posted March 18, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2013 Share 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. Link to comment Share on other sites More sharing options...
AZJIO Posted March 19, 2013 Author Share Posted March 19, 2013 Then you are right My other projects or all Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 19, 2013 Share 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. Link to comment Share on other sites More sharing options...
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