Er.. I was not guaranteeing anything. Just before posting the reply, I checked it all on my TC compiler, and the program ran perfectly.
You are right about integer sizes. For example, Dev C/C++ uses 4 bytes, TC uses 2 bytes, VC++ uses 4 bytes again. And not only integers, even pointers are provided 4 bytes in modern compilers.
You are also right that we cannot convert a pointer into an integer, or vice versa, simply because a pointer stores data in quite a different form than an integer, and we are forcing the compiler to implicitly perform conversion from one data type to another.
For example, if we write,
int i, *ptr; ..1
i=ptr; ..2
ptr=i; ..3
In line 2, I am forcing the compiler to convert data stored in pointer-form, into data which can be stored in an integer. The compiler may be successful in doing so at some times, but may fail miserably on many occasions, leading to wrong results or system failure.
Didn't I mention in my post that C should actually forbid this type of conversion. I am totally against such faulty techniques. But lqg was asking a question, and I told him what the right answer would be, if everything went right inside the computer.
warm regards
Mr V