G
grocery_stocker
How come you can subtract pointers, but you cannot add them?
grocery_stocker said:How come you can subtract pointers, but you cannot add them?
How come you can subtract pointers, but you cannot add them?
How come you can subtract pointers, but you cannot add them?
"grocery_stocker said:How come you can subtract pointers, but you cannot add them?
grocery_stocker said:How come you can subtract pointers, but you cannot add them?
grocery_stocker wrote:
What would such a construct mean?
"127 Main Street" minus "123 Main Street" equals "2 houses".
"127 Main Street" plus "123 Main Street" equals ?????.
The only thing I can think of where such a thing might actually
be -useful- has to do with the fact that in C, you are only
allowed to compare pointers if they point to the same object
(or no further than 1 past the object). It is, though, sometimes
useful to be able to compare pointers more generally -- e.g.,
in linked lists, if you want to compare a node pointer to
the list head pointer, then it's certainly not fun to
contemplate that the comparision result is undefined
if the two nodes were allocated in different malloc() calls...
>
> Depends. On my street, houses are generally 4 apart numerically.
> 555 is next to 559.
Depends. On my street, houses are generally 4 apart numerically.
555 is next to 559.
When 123 is adjacent to 127, then the result of the addition
would be an apartment block ;-)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.