- Word ..clause 1..: pointer
- ..clause 2..: Pointer type
- ..clause 3..: Pointer value
- ..clause 4..: Pointer variable
Though it explained that contents of the variable were able to be changed by passing the function the address of the variable in the foregoing paragraph
Though the variable that memorizes the value of the address is called a pointer at the people
This is not a too accurate in reality way to call.
Because the pointer is three function to treat the address generic name.
How of pointer to call is a generic name, and separates into three kinds accurately.
Eyes are pointer types of one.
The int type that has come out up to now, and it is double type and similar type.
However, there is a feature a little different from them for the pointer type.
The second is a pointer value.
This is a numerical value that can be treated by the pointer type, and, in short, an address.
There is a distinction of pointer value as well as the distinction of the numerical value like the integer and the real number, etc.
The third is a pointer variable.
This is a variable that can memorize the pointer value declared in the pointer type.
It is a variable of the int type, a variable of the double type, and basically the same thing.
Because it explains these three differences as follows
Read taking care [kongaraga].
The pointer type means the type of the variable that memorizes the address.
The pointer type has a side different from a usual type.
It is a point that it is a derived type from whom the pointer type is produced with other types.
It is not actually difficult so much though an explanation cramped as for what.
For instance, this is an independent type for the int type. The relation doesn't exist to other types either.
On the other hand, the pointer type unites and makes other types and the pointer types.
The type to int of pointer type can be done by uniting the int type to the pointer type.
The pointer type to double is produced in case of the double type.
Moreover, unite the pointer type to the pointer type to int further.
The pointer type to int of the multiple of pointer type of the pointer can even be made.
In short, the pointer type cannot exist in this world if it doesn't unite with other types.
So to speak, it is a type like the helminth.
By the way, the pointer type is a type of the variable that memorizes the address in short.
After all, the address ..integral value.. doesn't pass by as displayed in the start of this chapter.
Why should the type that memorizes the integral value unite with other types?
There is a tangible reason in this. The purpose is to take out the numerical value memorized at a specified address.
For instance, the int type, the double type, and the char type are different the size everything.
Because it is a size in four bytes in a standard compiler for the int type
As many as four lockers of memory that exists by hundred million units will be used.
Take it out bringing these four pieces together to take out the value of the int type.
According to the type because even the pronunciation of the binary number memorized in the memory might be different
The memorized numerical value cannot be taken out as long as it is not understood what an original type was.
In a word, it is necessary to understand the pointer type was an address of the variable of what type.
Then, if you make it as a pointer type in shape to unite beforehand with other variables
The numerical value memorized in the variable of the pointer type is understood as soon as it is a type that unites.
[ Void pointer ]
Actually, the pointer type that is single and exists includes the void type.
Though this type can be memorized even in the address of what variable
Because the type of an original variable is not understood, the value cannot be taken out.
What is the pointer value though is a numerical value to which the variable of the pointer type can be memorized?
In short, this is a value of the address of the variable.
It ..integral value without a mere sign.. doesn't pass with the pointer value in a lot of compilers.
If the mechanism of the memory of the computer is recalled, the reason might be understood at once.
The memory of the computer is a group of the locker of tens of hundred million.
The reason for the address is that it is a number applied to the locker.
However, one doubt remains here.
If you memorize it in the int type if the address is a mere integral value though it must be enough
Should I treat purposely as a new numerical value such as pointer values why?
Actually, it only has to memorize in the int type, and, in a sense, it can be said because that it will be the street.
Because the address and the int type become 32 bits in the compiler in 32 bits
There is not a problem in the place memorized in the int type without the sign either.
On the contrary, in B language who is the ancestor of C language
It was a mechanism that the address is memorized in the type that hit the int type of C language.
However, there is a reason so that it is treated by C language as a numerical value of pointer value.
First of all, the meaning is obviously different because of a pointer value and a usual integral value.
Though a usual integral value is a numerical value to calculate in the program
The reason for the pointer value is that it is not a numerical value used to calculate.
In short, it is first of all impossible to use a usual integral value as a pointer value.
The pointer value cannot be used to calculate as a usual integral value at the same time.
In a word, the purpose is complete though both of this two are mere integral values.
There is not an advantage even if both are treated from this by the variable of the int type either.
Be the numerical value memorized in the variable an integral value or a pointer value or it becomes cramped.
[Deareba] and rather assuming two to be a separate numerical value become very convenient.
The pointer variable is an actual variable declared in the pointer type.
The address of the variable of the type that became the origin can be freely substituted for this variable.
In addition, the memory of the memorized address can be read and be rewritten.
It is understood it has a character considerably different from the current variable from this.
Actually, the pointer variable has the function not provided in the current variable.
Even if what value is recorded, the variable has been done to use it for some calculations up to now.
However, never use it to calculate the memorized address value in the pointer variable.
The role of the pointer variable is to operate the memory of the memorized address.
Usually when paraphrasing it though it behaves as a pointer variable
It is necessary to transform to a usual variable when the memory operation is necessary.
Only this transformation function becomes the maximum feature of the pointer variable.
The pointer variable has two modes (a pointer variable mode and a usual variable mode).
It is possible to use it by switching of each if necessary.
In the pointer variable mode, it doesn't have a wonderful function.
Concretely, there are only substitution and an addition subtraction to the address.
Because it is only a memory of the address necessary for the pointer variable mode.
It is not necessary to do anything especially as long as the address is memorized now.
The character usually becomes quite the same as the variable when changing into the variable mode usually.
It is possible to calculate by using various operators by the favor as well as a usual variable.
Naturally, the memory used at that time becomes an address memorized in the pointer variable mode.
Though it only had to use as a variable the current variable usually
In the pointer variable, switch two modes appropriately.
Remember to have to use it properly.