In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
To study pointers, we need to deepen our understanding of the concept of memory address. For example, all memory is equivalent to a building with many rooms, each room has a room number, for example, from 101,102,103 to NNN, we can say that these room numbers are the address of the room. Every unit in the corresponding memory also has its own number, for example, from 0x00, 0x01, 0x02 to 0xNN, we can say that these numbers are the address of the memory unit. People can live in the room, and the corresponding memory unit can "live" variables: suppose a person named A lives in room 101. we can say that A's address is 101. maybe 101is the address of A. correspondingly, suppose a variable named x lives in the memory unit numbered 0x00, then we can say that the memory address of variable x is 0x00, or 0x00 is the address of variable x.
The basic unit of memory is bytes, and the English word is Byte. The STC89C52 single-chip microcomputer we use has a total of 512 bytes of RAM, which is what we call memory, but it is divided into external 256bytes and internal 256bytes. We only take the internal 256bytes as an example, it is very clear that the address number starts from 0 is 0x00~0xFF. We use the C language to define all kinds of variables within the address scale of 0x00~0xFF, and different types of variables will occupy a different number of memory units, that is, bytes, which can be combined with the C language variable types discussed later to deepen our understanding. Suppose it is said in the present world
Unsigned char a = 1; unsigned char b = 2; unsigned int c = 3; unsigned long d = 4
If we put these four variables in memory, they will look like those listed in Table 12-1. Let's first take a look at their storage methods.
Table 12-1 variable storage methods
The data stored in the memory address. 0x07d0x06d0x05d0x04d0x03c0x02c0x01b0x00a
Variables a, b, and c and d have different types of variables, so the storage units in memory are also different. An and b take up one byte, c takes 2 bytes, and d takes 4 bytes. So, the address of an is 0x00Magneb, the address of 0x01Magnec is 0x02Perry d, the address of their address is 0x04, and the expression of their address can be written as: & a dagger. This represents the address of the response variable, which is preceded by a variable in the C language & indicating the address of the variable, which is called the "address character" in this case.
At this point, there is an extension that everyone can understand: for example, the variable c is of unsigned int type, accounting for 2 bytes, stored in the memory addresses of 0x02 and 0x03, so is 0x02 its low byte or high byte?
This result is determined by the cooperation between the C compiler and the single-chip microcomputer architecture, and there are differences in the type of single-chip microcomputer, as long as everyone knows about it. For example: in the case of the Keil+51 single-chip microcomputer we use, 0x02 stores high bytes and 0x03 stores low bytes. This is a detailed result of the compilation of the bottom layer and does not affect the use of the lower layer. The following two situations are not affected by this detail: forced type conversion-b = (unsigned char) c, then the value of b must be the low byte of c; if you take the address-& c, then what must be lost must be 0x02, which is mostly decided by the C language itself and will not be changed because of the differences of the MCU compiler.
In practice, there are two ways to find a person, one is to find someone through its name, and the other is to find someone through its address. We in the police station household registration management piecemeal information output box, output Xiaoming's home address, bits and pieces will actively point to Xiaoming's relevant information, output Xiaogang's home address, bits and pieces will actively point to Xiaogang's relevant information. This box for us to output the address is called "address output box" in household registration management.
So, in C language, we want to visit a variable, there are two ways: one is to visit through the variable name, and the other is to visit through the address of the variable. In C language, the address is equal to the pointer, and the address of the variable is the pointer of the variable. We want to send the address to the so-called "address output box". This "address output box" can output not only the pointer of x, but also the pointer of y, so it is equivalent to a special variable-- the variable that holds the pointer. therefore, it is called a pointer variable, which is referred to as a pointer, and the pointer we usually talk about refers to the pointer variable.
Whose address is output in the address output box points to the information of this group, while the address of which popular variable is output to the pointer variable naturally points to the content of the variable, which is usually said that the pointer points to the variable.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.