int main(){

int near * ptr=( int *)0XFFFF;

return 0;

why the op is 3 and how to convert 0XFFFF into its decimal equivalent?

Recommended Answers

All 2 Replies

Well, this goes back to 16-bit addressing (as revealed by your use of near).
In 16 bits, the size of an int (being 16 bits) is 2 bytes.
You increment it twice. But the compiler knows it's an int pointer, so it increments it by 2 each time.
So you're adding 4 to a value already holding 0xFFFF. Adding 1 to 0xFFFF in 16 bits rolls over to zero. What do you figure you have left?

hey thanks......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.