# arithmetics of indicators

• Question of the arithmetics of indicator C. Let

``````int *p;
int *q;
int *o;
int i;
o = NULL;
``````

Let right. `p` and `q` points 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:

``````p-o;
o-p;
``````

What happens if you're allowed? On the one hand `o` It doesn't point to the same body, and it doesn't, but it's also normal. `0`and 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` Not flat `sizeof(int)`the expression `p-o` must return the fragmented number of elements that cannot be.

The expression `p-NULL` It could only be true if `NULL` - That's it. `#define NULL 0`and not valid if, for example, `NULL` defined as `(void*)0` (in C). Since the standard does not indicate how to be defined `NULL`it should be assumed that the expression `p-NULL` No, it's not.

Note: expression `p-0` Alive and still `p`but it only works for a whole number `0`

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2