0

int main(){

int near * ptr=( int *)0XFFFF;
ptr++;
ptr++;
printf(“%p”,ptr);


return 0;
}

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

Edited by shuchi0113: n/a

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by shuchi0113
0

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?

Edited by DeanMSands3: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.