In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the knowledge points of variables and data types in C language". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the knowledge points of variables and data types in C language?"
I. variables
In our daily life, we always get used to putting bits and pieces in boxes or drawers, first, to make our room look less messy, and second, to make it easy to find later.
The same is true in computers, we always need to find an area in memory, stipulate to use it to store the data to be stored, and then give it a memorable name, which is convenient to use or find later. And this area is equivalent to a box or drawer, and the data we want to store is equivalent to our belongings.
In C, it is like this to find an area in memory:
Int a
The int here, which stands for integer, means an integer, that is, to determine the type of data we want to store. An is the name of this area, and of course its name can be played as you like, as long as it conforms to the naming convention.
Now that the "box" of "packing" has been found, how to put "things in the box"?
The C language stores data in memory like this:
A = 100
The = here is called "equal sign" in mathematics, while in computer programming language, this symbol is called "assignment", which means to assign a value to this allocated area of memory. That is, the process of putting data into data memory.
In the C language, you can also put the above two pieces of code together directly:
Int aura 100
The representation of this code is the same as the above two combined. In addition, the integer in an is not immutable, as long as we want to change, then it will change at any time according to our needs, the way to change is to assign values again:
Int axiom 100 per share 99 per cent 101
If the second assignment is made, the second assignment will overwrite the first assignment, that is, if the result of an is finally printed, then the value of a can only be 101, and the previous 100 and 99 have been overwritten.
Therefore, the value of a can be changed, so it has a very vivid name, called a variable, as the name implies, a quantity that will change.
Int a; this process is called defining variables.
A = 100; this process is called variable assignment, the first assignment, and can also be called variable initialization.
2. Data type
In a computer, data such as numbers, text, symbols, graphics, audio or video are stored in memory in binary form, and they are essentially the same. So the question is, should 00010000 be understood as the number 16, or the color of a pixel in the image, or should it make a certain sound? If there is no special explanation, we will not be able to tell the difference between them.
In this way, the data in memory can be interpreted in many ways, and we must determine the type of data before using it. The above-mentioned int a; means that only integers can be stored in an and cannot be understood as pixels or sound. And int also has a special name, called data type (Data Type).
Literally, data types, that is, used to indicate the type of data, determine how the data is interpreted, so that computers and programmers do not have ambiguity.
Third, expand the continuous definition of multiple variables
The degree of simplicity of the program, one is to make the whole program look clearer, and the other is to make it easier to modify and read later. When defining a variable, if it is only for the same data type, we can say as follows:
Int a _ r _ b _ rec _ tinct float x _ 1 _ 2, y _ y 2.1, z _ r 3.0 _ x _ char p, qure _ blank _ a'
To define variables sequentially, multiple variables need to be separated by commas, and they must be of the same data type. These variables can be initialized or not initialized.
The length of the data
The length of the data refers to the amount of memory occupied by the data, that is, the number of bytes.
The more bytes you consume, the more data you can store. In the case of numbers, you can store larger values. On the other hand, if the space is limited, the stored value is small.
At this point, I believe you have a deeper understanding of "what are the knowledge points of variables and data types in C language?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.