Null Pointer Assignment

But both addition and subtraction have a slightly different behavior with pointers, according to the size of the data type to which they point.

When fundamental data types were introduced, we saw that types have different sizes.

Fortunately, that task is left to the environment where the program is run - generally, an operating system that decides the particular memory locations on runtime.

However, it may be useful for a program to be able to obtain the address of a variable during runtime in order to access data cells that are at a certain position relative to it.

The meaning of an expression using the dereference operator (*) is very different from one that does not.

When this operator precedes the pointer name, the expression refers to the value being pointed, while when a pointer name appears without this operator, it refers to the value of the pointer itself (i.e., the address of what the pointer is pointing to).

Pointers can be initialized either to the address of a variable (such as in the case above), or to the value of another pointer (or array): To conduct arithmetical operations on pointers is a little different than to conduct them on regular integer types.

To begin with, only addition and subtraction operations are allowed; the others make no sense in the world of pointers.

The concept of arrays is related to that of pointers.

In fact, arrays work very much like pointers to their first elements, and, actually, an array can always be implicitly converted to the pointer of the proper type.

SHOW COMMENTS

Comments Null Pointer Assignment

The Latest from irkcenter.ru ©