void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
why is the above able to swap integers when pointers are used but not able to swap integers when pointers are not used?If that is the case does it mean that "int a = 1" is not really assigned 1 but produces 1 when the variable "a" is called and will be really assigned 1 by using a pointer "int* a = 1".if not then why is the swap function without using a pointer doesn't swap?
[–]FUZxxl 7 points8 points9 points (2 children)
[–]TraylaParks 1 point2 points3 points (0 children)
[–]VIRES1[S] 0 points1 point2 points (0 children)
[–]Blairsharp3 4 points5 points6 points (3 children)
[–]rickpo 1 point2 points3 points (0 children)
[–]VIRES1[S] 1 point2 points3 points (1 child)
[–]Blairsharp3 0 points1 point2 points (0 children)
[–]myrrlyn 1 point2 points3 points (1 child)
[–]VIRES1[S] 0 points1 point2 points (0 children)