/* * ====================================================================== * Function to Swap Two integers (correct implementation) * * Copyright (C) 1993-96 by Mark Austin and David Mazzoni. * * This software is provided "as is" without express or implied warranty. * Permission is granted to use this software on any computer system, * and to redistribute it freely, subject to the following restrictions: * * 1. The authors are not responsible for the consequences of use of * this software, even if they arise from defects in the software. * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * 4. This notice is to remain intact. * ====================================================================== */ void SwapInts( int *ipVal1, int *ipVal2 ) { int iTemp; iTemp = *ipVal1; *ipVal1 = *ipVal2; *ipVal2 = iTemp; } int main( void ) { int iVal1 = 100; int iVal2 = 200; printf("*** In main() : iVal1 = %i iVal2 = %i\n", iVal1, iVal2 ); printf("*** In main() : Go to SwapInts()\n"); SwapInts( &iVal1, &iVal2 ); printf("*** In main() : Back from SwapInts()\n"); printf("*** In main() : iVal1 = %i iVal2 = %i\n", iVal1, iVal2 ); }