C
Chad
Given something like the following
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
How does having a temp variable allow for anything to safely swap with
itself? Like for example x = 10 and y = 10. What would happen in the
absence of temp?
Chad
void swap(int *x, int *y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
How does having a temp variable allow for anything to safely swap with
itself? Like for example x = 10 and y = 10. What would happen in the
absence of temp?
Chad