Skip to content

Instantly share code, notes, and snippets.

@y-yu
Created November 20, 2012 11:23
Show Gist options
  • Save y-yu/4117377 to your computer and use it in GitHub Desktop.
Save y-yu/4117377 to your computer and use it in GitHub Desktop.
7-2
#include <stdio.h>
void swap_array (int a[], int i, int j) {
int t = a[i];
a[i] = a[j];
a[j] = t;
}
int main () {
int i;
int a[] = {0, 1, 2, 3, 4, 5, 6};
swap_array(a, 3, 4);
for (i=0; i<sizeof(a)/sizeof(a[0]); i++)
printf("%d\n", a[i]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment