Tag: Take address operation C language memory address
About the C-language address, the address-taking operator &
2015-04-14 Qingdao Zhang Junhao
Today in the Forum bar to see the C language operator "&" problem, because before you learn C language also encountered this problem, just tidy up the idea of replies, also by the way to organize into a blog ~
int A;
scanf ("%d ", &a);
Our teacher said,& is the address, but I wonder, why call the address?
We really want to know how much a is, not where it is, the address is not to describe a thing where? I lose a 10,a is 10.
Well, personal feeling C is a very "hard" language, because it is closer to the bottom of the hardware than the other high-level languages, and the cumbersome underlying processor instruction programming is out of order with respect to the machine instruction assembly.
the inability to understand "&" or "Address" or "address" is because you are standing at the level of the Advanced (natural language) language, not the machine itself. Any variable is data, the data will be on the hardware machine has his storage space, storage space has a corresponding location, to facilitate our operation of this storage space, such as memory, memory address.
Here we define a variable a, such as int A, is actually reserved a storage space, storage space has a corresponding location, we use the symbol "a" to refer to, when we compile high-level language, the compiler will take us to the variable a operation, to the corresponding storage space operations.
There are essentially two types of operations, inputs, and outputs for a piece of storage space. A = 1;//is the input to the storage space, that is, we call the left value, the data "1" write to the variable a corresponding storage space; b= a;//is the output of the storage space, the memory of the variable a corresponding to the data output, that is, we call the right value, write variable b corresponding to the space.
int scanf (char *format[,argument,...]), the parameter in the function is called in the format: scanf ("< formatted string >",< Address Table >);
If you write scanf ("%d", a), we are outputting the data in the storage space where variable A is located, while the value of a variable in scanf is used as the keyboard terminal character to enter the address of the storage space, which is obviously unreasonable, Because we want to designators the character of the keyboard terminal input to the storage space where variable a resides, not the memory space that the data stored by variable A is pointing to ~ so write scanf ("%d", &a);//"&" is an operator that can get the storage space where variable A is located, Instead of the data stored in the storage space where variable A is located ~
About the C-language take address operator "&"