Skip to content

Instantly share code, notes, and snippets.

@y-yu
Last active December 11, 2015 01:29
Show Gist options
  • Select an option

  • Save y-yu/4524177 to your computer and use it in GitHub Desktop.

Select an option

Save y-yu/4524177 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void swap_array(int a[], int x, int y)
{
int t = a[x];
a[x] = a[y];
a[y] = 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