[Solved] Write a program that swaps values within an array [closed]
There’s several problems with your code. First, the swap function doesn’t work. You’re swapping the values of the pointers that are local variables inside the function, you’re not swapping the array elements they point to. You need to indirect through pointers to get the values. int temp1 = *a; *a = *b; *b = temp1; … Read more