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!!!
Here is the tester:
#import <stdio.h>
void swap( int ary[] );
int main( int argc, char*argv[] )
{
int ary[] = { 25, 50 };
printf( "The array values are: %i and %i \n", ary[0], ary[1] );
swap( ary );
printf( "After swaping the values are: %i and %i \n", ary[0], ary[1] );
return 0;
}
Here is the swap function:
void swap( int ary[] )
{
int temp = *ary;
*ary = *(ary + 1);
*ary = temp;
}
This is what is displayed after running:
The array values are: 25 and 50
After swaping the values are: 25 and 50