Link Search Menu Expand Document

Below is our example C file, swap.c, from class today.

#include <stdio.h>

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int main() {
    int x = 6;
    int y = 3;

    printf("%d %d\n", x, y);
    swap(&x, &y);
    printf("%d %d\n", x, y);


    return 0;
}

Download


Copyright © 2022 John Hott, portions Luther Tychonievich.
Released under the CC-BY-NC-SA 4.0 license.
Creative Commons License