Swapping two integers using pointers using c -
i trying swap value of 2 integers using pointers, see code below: swapping number using pointer in c:
{ int = 10; int b = 20; swapr(&a, &b); printf("a=%d\n", a); printf("b=%d\n", b); return 0; } void swapr(int *x, int *y) //function { int t; t=*x; *x=*y; *y=t; } in code why swap(&a, &b); used when *x , *y point value not address
when (int *x, int *y) you're declaring x , y pointers. in future usages, when x, means pointer , when *x, means value points to.
Comments
Post a Comment