This article is only suitable for friends in the C language. Anyone who has learned more than a few months.
What is the most characteristic of C language? pointer. This answer seems to be an agencies, no matter whether the master is still a low hand, the rookie is still a old bird, I haven't learned it, but if you have heard of C, I can answer. It is because C introduced into the concept of pointer, so that he is a high-level language closest to the real model of the machine, so that the title of "Intermediate Language"; I sometimes compile more people in Class Class more deep - Single chip programming, I will only compile, although I started to learn C, still feel weird.
Therefore, the pointer is to learn c must be mastered. If you fear it, it is better to change the language without a pointer. There is a small example below, I hope you can get some inspiration.
#include
void main ()
{
INT A = 10000; / * ------- 1 * /
INT * P, D; / * -------------- 2 * /
P = & d; / * --------------- 3 * /
P = (int *) a; / * ----------- 4 * /
Printf ("% D% D", A, * P);
}
Let me briefly explain:
Is this written INT * P good or write int * P?
These two usage are ok, and each write has an advocator. The pointer operator is combined to the right. If you write like 2 statements, actually D is the int type, rather than the pointer type, and Int * P Writing is for this reason. You said that I pinched int * cracked up, but the compiler would make such a way of writing as a type conversion, not a type definition. The reason is intuitive, the reason is intuitive, very clear representation P is an integer pointer. For example, such a way of writing int * p = & a; replaced with int * p = & a; it is very puzzled. In order to avoid misunderstandings of 2 statements, there is a rule that one line only defines a pointer.
How to write, to see personal habits, each write legal person is recognized.
Risk of pointers
The pointer is actually a variable with memory addresses, which is equivalent to indirect addressing with pointer access. Obviously, you can give different values to the needle, so you can access any memory - too dangerous, such as 4 statements. In the 16-bit system, you have no way to this use. Fortunately, in the 32-bit system, this use is banned.
Type of pointer
You said that the pointer is not a variable with a memory address, since it is a "memory address" type, what is going to do. But it should be noted that when you restore from the pointer, the memory it points to, is it used in accordance with the integer? From this perspective, when you know the content of the memory pointed to by the pointer, it is also allowed.
About pointers, each C language book has a very detailed introduction, I will not say more. When you have a coarse understanding of compilation, I believe you will have a more profound understanding of the pointer.