Re: swap of two no.?????



imnilima@xxxxxxxxx:

i want to know that how to swap 2 values ,that is one is integer &
other is float using pointers in C.


void SwapIntWithFloat(int *const pi,float *const pf)
{
int const temp i = *pi;
*pi = *pf;
*pf = i;
}


You might want some safe-guard such as:

assert(pi); assert(pf);

assert(*pf>=INT_MIN && *pf<=INT_MAX);

--

Frederick Gotham
.



Relevant Pages