Hi, I'm newbie in C and just learning about pointers and having problem with a program code. That was, SWAPPING using pointers. Can anyone please tell me that?
Here is the code... Code: #include<stdio.h> #include<conio.h> void swap(int*, int*); void main() { int i,j; clrscr(); printf("Enter the value of i and j respectively:"); scanf("%d %d",&i,&j); swap(&i,&j); printf("%d %d",i,j); getch(); } void swap(int *i, int *j) { int k; k=*i; *i=*j; *j=k; printf("%d "%d",*i,*j); }
Please note this post for more discussions on Swapping! http://www.cfanatic.com/showthread.php?t=1970