/* ECP: FILEname=fig6_13.c */ /* 1*/ void * Swaps Where X And Y Point, Not Their Value */ /* 2*/ WrongSwap1( const int *X, const int *Y ) /* 3*/ { /* 4*/ const int *Tmp; /* 5*/ Tmp = X; /* 6*/ X = Y; /* Would Be Caught By Compiler If The */ /* 7*/ Y = Tmp; /* const Directive Was Used Correctly */ /* 8*/ } /* 1*/ void /* Can Lead To A Difficult To Track Down Bug */ /* 2*/ WrongSwap2( int * const X, int * const Y ) /* 3*/ { /* 4*/ int *Tmp; /* Pointer Not Needed To Store The int */ /* 5*/ *Tmp = *X; /* Major Error: Tmp Is Uninitialized */ /* 6*/ *X = *Y; /* 7*/ *Y = *Tmp; /* 8*/ }