/*--------------------------------------------------------------------*/ /* testswap.c */ /* Author: Bob Dondero */ /* Using pointers to implement call by reference. */ /*--------------------------------------------------------------------*/ #include /*--------------------------------------------------------------------*/ static void swap(int *piFirst, int *piSecond) /* Swap the values of *piFirst and *piSecond. */ { int iTemp; iTemp = *piFirst; *piFirst = *piSecond; *piSecond = iTemp; } /*--------------------------------------------------------------------*/ int main(void) /* Test the swap function. Return 0. */ { int i1 = 8; int i2 = 12; printf("Before: %d %d\n", i1, i2); swap(&i1, &i2); printf("After: %d %d\n", i1, i2); return 0; } /* Sample Execution: $ testswap Before: 8 12 After: 12 8 */