C language data, constants, and variables
Picture text, etc. are data, in the calculation of 0 and 1 storage
I. Classification
Data is divided into static data and dynamic Data.
1. Static data: Some permanent data, generally stored in the hard disk, as long as the hard disk is not damaged data are present
Generally stored in the form of files on the hard disk, the computer shutdown startup still exists
2. Dynamic Data: During the process of running the program, the temporary data generated dynamically, generally stored in memory, memory storage space is generally small, the computer shuts down
The data is erased, the software or the computer shuts down, and the temporary data is erased.
3. Static data and dynamic data can be converted.
4. Why not store the dynamic data to the hard drive? Because the direct access memory is faster, the software is installed on the hard disk and runs in memory. Programmers should be more concerned
Memory data.
Two. Data size
1. So the data are all 0 and 1 components
2. The data has the size, the static data occupies the hard disk space, the dynamic Data occupies the memory space.
3. The larger the data, the more 0 and 1 are included.
4. The units in which the data is stored are bits and bytes, and a 0 or 1 is a bit, or 1bit.
5. In the computer, data is stored in bytes. 1 bytes = 8 bits (1byte=8bit).
6.1tb=1024gb,1gb=1024mb,1mb=1024kb,1kb=1024b.
Three. The role of variables
Initialize: two forms.
1.int num; num=1027;
2.int num=1027;
Modify: You can modify the value of a variable and assign it multiple times to overwrite it.
Output: Use placeholder output variables. Placeholders for various types
Int%d or%i
Float/double%f (output 6 bits By default, can be controlled using. 2f)
Long%ld
Long Long%lld
Char%c
String%s
Unsigned Long%zd
Four. Use of variables note
Variable scope: Starts from the line defined by the variable until the end of the code block.
return; exit the function to clear the in-memory data
Use rectangular boxes and Excel to analyze memory
The role of code block {}: can be used to improve performance, instant recovery of unused variables
05.C language data, constants, and variables