I have this code fragment
int i = 5;
int k = 7;
int * iPtr;
int * jPtr;
int * kPtr;
iPtr = &i;
kPtr = &k;
I am required to swap i and k using the pointers. This is how I'm doing it:
*jPtr = *kPtr ;
*kPtr = *iPtr ;
*iPtr = *jPtr ;
Is this the best way to do it, or is there a better way?