I am supposed to use pointers to swap ints in an array. It compiles with no errors or warnings and runs but does not swap the ints. Any suggestions would be helpful!!!
just for fun; It's also possible to swap without using a temporary value
void swap( int ary[] )
{
*ary ^= *(ary + 1);
*(ary + 1) ^= *ary;
*ary ^= *(ary + 1);
}
As GMan points out, this code obscures your intent from the compiler and the processor, so the performance may be worse than using a temp variable, especially on a modern CPU.