]> Pileus Git - ~andy/sfvlug/blobdiff - c/src/swap.c
Add C notes.
[~andy/sfvlug] / c / src / swap.c
diff --git a/c/src/swap.c b/c/src/swap.c
new file mode 100644 (file)
index 0000000..5219c32
--- /dev/null
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+void swap(int *a, int *b)
+{
+       *a ^= *b;
+       *b ^= *a;
+       *a ^= *b;
+}
+
+int main(int argc, char **argv)
+{
+       int a = 5678;
+       int b = 1234;
+
+       swap(&a, &b);
+       printf("%d %d\n", a, b);
+
+       return 0;
+}