It's a basic question I created a function that swaps pointer addresses with each other, but when I print it out, it becomes the original value. Debugging doesn't solve the question!
The desired result is 3020.
The real result is 2030.c++
Swap function is created incorrectly. The code in the question creates an int-type pointer variable, which is a local variable called a and b, and then replaces the address values stored in the two pointer variables, a and b, within the function.
What you actually have to do is change the values that are stored in the memory for each address through the address value that is given initially. You need to use the *speaker to access memory. Please refer to the code below.
© 2022 pinfo. All rights reserved.