Created
September 5, 2014 13:58
-
-
Save pori/c642a18981b2cbbefb62 to your computer and use it in GitHub Desktop.
An array value swap example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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