In article <11**********************@m73g2000cwd.googlegroups .com>,
im******@gmail.com <im******@gmail.comwrote:
>i want to know that how to swap 2 values ,that is one is integer &
other is float using pointers in C.
Could you clarify what you mean? If your pointers are I and F to
start, then afterwards you want I to point to the float and F to
point to the int -- a pointer operation? Or you want the memory location
that used to hold the int to now hold the float and vice versa?
If so, with or without I and F being updated to point to the new locations?
If you are trying to change the pointers without moving the memory,
then you have the problem that the pointers would point to the wrong
types afterwards -- you cannot use an int pointer to point to a float.
If you are trying ot change the memory locations, then you have
the problem that int and float may be different sizes, so when you
move one of them there might not be enough room at the destination.
It is not uncommon for floats to have to be aligned on addresses that
are internally multiples of 4 bytes, but for int to only be restricted
to multiple of 2 bytes, so you can run into alignment problems even if
everything else worked out.
--
Prototypes are supertypes of their clones. -- maplesoft