当前位置:网站首页>C language - Introduction - Foundation - syntax - data type (4)
C language - Introduction - Foundation - syntax - data type (4)
2022-07-04 08:49:00 【Hu Anmin】
What is data ?
Dealing with data all the time in life
- for example : People's weight 、 height 、 income 、 Gender and other data
- In the process of using computers , Will also be exposed to a variety of data
- for example : Document data 、 Picture data 、 Video data, etc
data classification
Static data
- Static data refers to some permanent data , It's usually stored on a hard disk . The storage space of hard disk is generally large , Now the hard disk of ordinary computer has 500G about , Therefore, some large files can be stored in the hard disk
- The length of storage : Turn on the computer after it is turned off , The data is still there , As long as you don't take the initiative to delete or the hard disk is not broken , The data will always be
- Which are static data : Static data is usually stored on the hard disk in the form of files , Like documents 、 Photo 、 Video etc. .
Dynamic data
- Dynamic data refers to the process of running a program , Temporary data generated dynamically , Generally stored in memory . The memory space is generally small , Now the memory of ordinary computer is only 8G about , So use memory with caution , Don't occupy too much space
Storage space- The length of storage : After the computer is turned off , These temporary data will be cleared
- Which are dynamic data : When running a program ( Software ) when , The whole program will be loaded into memory , While the program is running , All kinds of temporary data are generated , These temporary data are stored in memory . When a program stops running or the computer is forced to shut down , All temporary data generated by this program will be cleared .
Since the hard disk has so much storage space , Why not load all the applications into the hard disk to execute ?
- The main reason is that the access speed of memory is faster than that of hard disk N times
- Conversion between static data and dynamic data , That is, load from disk to memory
- Conversion between dynamic data and static data , That is, save from memory to disk
As a programmer , What we care about most is the dynamic data in memory , Because the program we write runs in memory , All kinds of temporary data will be generated during the operation of the program , In order to facilitate the calculation and operation of data , C Language classifies these data , Provides a wealth of data types
Data type introduction
C The data types of languages are : Basic types 、 Empty type 、 Construct type and pointer type . The construction type includes the common body 、 Array 、 There are three types of structures . Basic types also include integers 、 floating-point 、 There are four types of characters and enumerations .

stay C In language , Numbers or Chinese characters that carry a series of information are data types , Computers cannot directly recognize different types , Therefore, when using a variable, you need to specify its data type in the declaration statement .C The data type of the language , Popular understanding is to put different items in different boxes , For example, decimals are stored in floating point 、 Integers are stored in integer 、 Characters are stored in character type and so on , Writing C The language needs to be different according to the stored data , Define different types of variables .
for example :int Integers are generally allocated 4 Bytes of storage space ,double Double precision floating-point allocation 8 Bytes of storage space ; The data type of a variable also determines what values the variable can take and what operations it can perform . For example, integer type can only be rounded , Decimal type can represent decimal , Integers and decimals can be added, subtracted, multiplied and divided .
Basic data type
C The most basic data type of a language is arithmetic , Including integer type and floating point number type . Character type 、 Enumeration types are also integer types in nature ; Integer type subdivides signed and unsigned integers 、 Long and short integers ; The difference between different integer types is that the storage length is different 、 The value range is different ; Floating point number type is relatively simple , It's all symbolic , It is divided into single precision and double precision floating-point numbers .
Integer types and declaration keywords include :
- Character type :
char( Whether it is signed or unsigned is customized by the compiler ) - Signed character type :
signed char - The unsigned character type :
unsigned char - Signed short integers :
short,signed short,short int,signed short int - Unsigned short :
unsigned short,unsigned short int - signed int :
int,signed,signed int - Unsigned integer :
unsigned,unsigned int - Signed long integer :
long,signed long,long int,signed long int - Unsigned long :
unsigned long,unsigned long int
Floating point type declarations include :
- Single precision floating point :
float - Double precision floating point :
double - Long double precision floating point :
long double
Common basic data type size
char 1 byte ,int 4 byte , long 8 byte ,float 4 byte ,double 8 byte ; Storage space size of each type , Number of bytes taken , It is related to the number of digits in the computer , Different machine data types have different sizes , Can pass sizeof() Keyword to calculate the size of each type , Determine the storage space and value range .
Get the variable size of the current machine
#include<stdio.h>
int main()
{
printf("int = %d\n",sizeof(int));
printf("short = %d\n",sizeof(short));
printf("long int = %d\n",sizeof(long int));
printf("long long int = %d\n",sizeof(long long int));
printf("char = %d\n",sizeof(char));
printf("_Bool = %d\n",sizeof(_Bool));
printf("float = %d\n",sizeof(float));
printf("double = %d\n",sizeof(double));
printf("long double = %d\n",sizeof(long double));
}

32 Bit compiler and 64 Bit compiler differences
32 Bit compiler
- char :1 Bytes
- char*( That is, pointer variable ): 4 Bytes (32 The addressing space of bits is 2^32, namely 32 individual bit, That is to say 4 Bytes )
- short int : 2 Bytes
- int: 4 Bytes
- unsigned int : 4 Bytes
- float: 4 Bytes
- double: 8 Bytes
- long: 4 Bytes
- long long: 8 Bytes
- unsigned long: 4 Bytes
64 Bit compiler ( At present, they are basically 64 Of course. )
- char :1 Bytes
- char*( That is, pointer variable ): 8 Bytes
- short int : 2 Bytes
- int: 4 Bytes
- unsigned int : 4 Bytes
- float: 4 Bytes
- double: 8 Bytes
- long: 8 Bytes
- long long: 8 Bytes
- unsigned long: 8 Bytes


边栏推荐
- Awk from getting started to digging in (11) detailed explanation of awk getline function
- The upper layer route cannot Ping the lower layer route
- 4 small ways to make your Tiktok video clearer
- Educational Codeforces Round 119 (Rated for Div. 2)
- What sparks can applet container technology collide with IOT
- 09 softmax regression + loss function
- Group programming ladder race - exercise set l1-006 continuity factor
- How to play dapr without kubernetes?
- Bishi blog (13) -- oral arithmetic test app
- High order phase difference such as smear caused by myopic surgery
猜你喜欢

DM8 tablespace backup and recovery
![Leetcode topic [array] -136- numbers that appear only once](/img/6d/f2e4b812e5dd872fbeb43732d6f27f.jpg)
Leetcode topic [array] -136- numbers that appear only once

Sequence model

What exactly is DAAS data as a service? Don't be misled by other DAAS concepts

Live in a dream, only do things you don't say
](/img/5a/c6a3c5cd8038d17c5b0ead2ad52764.png)
C语言-入门-基础-语法-[主函数,头文件](二)

Bishi blog (13) -- oral arithmetic test app

微服务入门:Gateway网关

Developers really review CSDN question and answer function, and there are many improvements~

Azure ad domain service (II) configure azure file share disk sharing for machines in the domain service
随机推荐
Flutter integrated amap_ flutter_ location
awk从入门到入土(7)条件语句
Awk from entry to earth (15) awk executes external commands
awk从入门到入土(14)awk输出重定向
Group programming ladder race - exercise set l1-006 continuity factor
Awk from entry to earth (14) awk output redirection
C, Numerical Recipes in C, solution of linear algebraic equations, Gauss Jordan elimination method, source code
Démarrage des microservices: passerelle
How to solve the problem of computer jam and slow down
Bishi blog (13) -- oral arithmetic test app
How can we make a monthly income of more than 10000? We media people with low income come and have a look
[untitled] 2022 polymerization process analysis and polymerization process simulation examination
How to solve the problem that computers often flash
Snipaste convenient screenshot software, which can be copied on the screen
Codeforces Round #793 (Div. 2)(A-D)
09 softmax regression + loss function
2022 gas examination registration and free gas examination questions
[Chongqing Guangdong education] National Open University spring 2019 455 logistics practice reference questions
Awk from getting started to digging in (9) circular statement
A single element in an ordered array