The value transfer function does not change the values of two variables.
Why, because it is only necessary to change the value of a parameter in a function to call a value.
The value pointed to by the address changes not only within the function, but also outside the function.
See the Code:
1 # include <stdio. h>
2 # include <stdlib. h>
3
4 void swap1 (int x, int y)
5 {
6 int temp;
7
8 temp = X;
9 x = y;
10 y = temp;
11 printf ("output % d \ n", X, Y in the value passing function );
12}
13
14 void swap2 (int * X, int * Y)
15 {
16 int temp;
17 temp = * X;
18 * x = * Y;
19 * Y = temp;
20 printf ("output % d \ n in the address passing function", * X, * y );
21}
22
23 int main (INT argc, char * argv [])
24 {
25 int x = 10;
26 int y = 0;
27
28 printf ("x y \ n ");
29 printf ("Initial Value % d \ n", x, y );
30 // value passing subroutine call (SWAP xy)
31 swap1 (x, y );
32 printf ("calling % d \ n", x, y outside the value passing function );
33
34 // call the address character Transfer Program (SWAP x, y)
35 swap2 (& X, & Y );
36 printf ("calling outside the Address Transfer Function % d \ n", x, y );
37 system ("pause ");
38 return 0;
39}
40