Meaning of offset

30 views
Skip to first unread message

gchi...@gmail.com

unread,
Oct 13, 2020, 4:36:25 AM10/13/20
to cmpt-295-sfu
The word offset is often used during pointer arithmetic, but what does it exactly mean? Until now I am assuming displacement but I am not sure if that's it. A clarification would be appreciated

Arrvindh Shriraman

unread,
Oct 13, 2020, 3:00:23 PM10/13/20
to cmpt-295-sfu
arithmetic difference between two integer values. If you consider each pointer as an unsigned int
offset = ptr2 - ptr1 is offset of ptr2 wrt to ptr1 i.e., ptr1 + offset  = ptr2

gchi...@gmail.com

unread,
Oct 13, 2020, 3:48:55 PM10/13/20
to cmpt-295-sfu
Thanks, that clears it up
Reply all
Reply to author
Forward
0 new messages