int * y = &x; /* read: the type of y is the address of an integer. Its value is the address of x. */
void swap(int x, int y) {
int temp = x;
x = y;
y = temp;
}
in the following program
int a = 2; int b = 3; swap(a, b);will leave a and b unchanged. But if we write instead
void swap(int *x, int *y) {
int temp = *x;
*x = *y;
*y = temp;
}
and call with
int a = 2; int b = 3; swap(&a, &b);now the values of a and b are truly swapped.