Skip to content

Instantly share code, notes, and snippets.

@pori
Created September 5, 2014 13:58
Show Gist options
  • Save pori/c642a18981b2cbbefb62 to your computer and use it in GitHub Desktop.
Save pori/c642a18981b2cbbefb62 to your computer and use it in GitHub Desktop.
An array value swap example.
#include <stdio.h>
void swap(int * set, int i, int j);
int main() {
int set[] = { 1, 2 };
swap(set, 0, 1);
printf("{ %d, %d }\n", set[0], set[1]);
return 0;
}
void swap(int * set, int i, int j) {
int temp = set[i];
set[i] = set[j];
set[j] = temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment