boot.dev lesson answers for the course: Learn Memory Management in C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

16 lines
204 B

void swap_ints(int *a, int *b) {
if (a == b) return;
// Either:
int tmp = *a;
*a = *b;
*b = tmp;
// Or:
// Below works, but is kind of a meme answer
// *a ^= *b;
// *b ^= *a;
// *a ^= *b;
}