------------------------------------------------------------------------------
MC logo
Swap Using Pointers
[^] Code Examples
------------------------------------------------------------------------------
<<Basic Pointers swap.c Arrays and Pointers>>
#include <stdio.h>

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

main()
{
        int x = 15, y = 74;
        printf("%d %d\n", x, y);
        swap(&x, &y);
        printf("%d %d\n", x, y);
}

Reading: pp. 48-49
<<Basic Pointers Arrays and Pointers>>