arithmetics of indicators
Question of the arithmetics of indicator C. Let
int *p; int *q; int *o; int i; o = NULL;
qpoints to the different elements of the same body. Permissibility of expression (i, naturally, is defined):
p+i; q-i; p-q;
Is it permissible to:
What happens if you're allowed? On the one hand
oIt doesn't point to the same body, and it doesn't, but it's also normal.
0and the first one, I think so.
No, not allowed♪
Standard C++ says http://eel.is/c++draft/expr.add#5 that if the two indicators do not belong to one body, the conduct is not defined.
The result of the deduction of the two indexes is the number of elements between them. If
p-omust return the fragmented number of elements that cannot be.
p-NULLIt could only be true if
NULL- That's it.
#define NULL 0and not valid if, for example,
(void*)0(in C). Since the standard does not indicate how to be defined
NULLit should be assumed that the expression
p-NULLNo, it's not.
p-0Alive and still
pbut it only works for a whole number