当前位置:网站首页>Subtotal of C language -- basic data types and their representations
Subtotal of C language -- basic data types and their representations
2022-06-29 06:18:00 【Chlorella of bit】
c The basic data types of the language include integer data 、 Real data and character data .
【1】 Constants and variables
(1) Constant
A constant is an amount whose value cannot be changed while a program is running , It is c One of the basic data objects used in the . Constants are divided into numerical constants and character constants , Numerical constants are divided into integer constants and real constants , Character constants are divided into character constants and string constants .
These types determine the size of the space occupied by various constants and the representation range of numbers .
(2) Symbolic constant
stay c In language , Constants are expressed directly in the form of their own existence , It can also be represented by an identifier , Symbolic constants .
c Language uses macro definition commands to define symbolic constants , Its definition is as follows :
#define identifier Constant
among #define Is a special definer for macro definition commands , An identifier is the name of a constant , A constant can be any kind of constant .
The functions of macro definitions are : During compilation preprocessing , Replace all symbolic constants that appear after the macro definition command in the program with the corresponding constants in the macro definition command one by one . Therefore, symbolic constants are also called macro substitution names .
(3) Variable
A variable is an amount whose value can be changed during program operation . Variables here are two completely different concepts from variables in mathematics , stay c In language , Variable is the basic concept of data storage . We know , At the level of computer hardware , When the program is running, the data is stored by internal memory 、 Storage unit 、 Storage address and a series of related mechanisms , The reflection of these mechanisms in the programming language is the concept of variables .
A variable in a program can be regarded as a container for storing data . There are two basic operations on variables :{1} Put data values into variables , This operation is called : assignment ;{2} Get the current value of the variable to use , be called : Value . Variables have the property of holding values , After assignment , You will get this value every time you use this variable .
Programs use variables by their names . stay c In language , The variable name is the identifier of the variable , Its naming rules comply with all provisions of the identifier .
c The basic variable types provided by the language are : Numerical variable ( It is also divided into integer variables and real variables )、 Character variables 、 Pointer to the variable .
{ Definition of variables }
c Language program requirements , Each variable must first be defined , That is, to declare its existence first , To be able to use it . Defining variables requires two aspects of information : Variable name and its type , To determine its storage structure and make c Language compiler allocates storage space for defined variables .
【2】 Shaping data and its representation
(1) Integer types 、 Integer variables Be careful : Since the shaping data is represented by binary complement , So the range of negative numbers is larger
plastic 2 byte -32768~32767 (short\signed)int
Long integer 4 byte -2147483648~2147483647 long
Unsigned integer 2 byte 0~65535 unsigned
Unsigned long shaping 4 byte 0~4294967295
(2) integer constants
Decimal system
octal : In numbers 0 start Such as :056 It's equivalent to the decimal system 46 017 It's equivalent to the decimal system 15
Hexadecimal : With 0x perhaps 0X start hinder a,b,c,d,e,f It can also be capitalized . Such as :0x123 The decimal equivalent of 291
(3) Long integer constants
Add... After the constant l perhaps L that will do . for example :40000 Is an illegal decimal integer constant , but 40000L Is a legal decimal long constant .
【3】 Real data and its representation
边栏推荐
- The simple problem of leetcode is to divide an array into three parts equal to sum
- [deep learning] - maze task learning I (to realize the random movement of agents)
- Difference between static and final
- Jenkins operation Chapter 6 mail server sending build results
- How does MySQL implement distributed locks?
- Openfpga wishes you a happy Lantern Festival!
- How to hand over complex legacy systems?
- Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin
- 2022 recommended high-speed rail industry research report investment strategy industry development prospect market analysis (the attachment is a link to the online disk, and the report is continuously
- Leetcode simple question: judging the color of a grid on a chess board
猜你喜欢

JIRA basic usage sharing

Two houses with different colors and the farthest distance

Meta metauniverse female safety problems occur frequently. How to solve the relevant problems in the metauniverse?

Why can't the article be posted?

Installing modules in pycharm

Games101 Lecture 10 geometry 1 Notes

Top ten Devops best practices worthy of attention in 2022

2022 recommended high-speed rail industry research report investment strategy industry development prospect market analysis (the attachment is a link to the online disk, and the report is continuously

What is the "danksharding" of V God Kop on Valentine's day?
![Meso tetra (4-N, N, n-trimethylaminophenyl) porphyrin (ttmapp) /meso tetra - [4- (BOC threonine) aminophenyl] porphyrin (TAPP thr BOC) supplied by Qiyue](/img/a9/0869c4f39a96cff63d1e310292c46d.jpg)
Meso tetra (4-N, N, n-trimethylaminophenyl) porphyrin (ttmapp) /meso tetra - [4- (BOC threonine) aminophenyl] porphyrin (TAPP thr BOC) supplied by Qiyue
随机推荐
Why is there a packaging type?
Plugin
Quickly write MVVM code using source generators
Principle of screen printing adjustment of EDA (cadence and AD) software
Fault: administrator account cannot be selected for login
There are two ways for golang to develop mobile applications
[chromium] win10 vs2019 environment chromium configuration and compilation.
Difference between parametric continuity and geometric continuity
Establishing the development environment of esp8266
ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience
51 single chip microcomputer learning notes 7 -- Ultrasonic Ranging
About: deleting unwanted event log lists
P5 DS - component and document Association
2022-02 Microsoft vulnerability notification
Leetcode theme [array] -217- there are duplicate elements
Leetcode simple problem building arrays with stack operation
Why are keys unordered in golang map
Research Report on the new energy industry of recommended power equipment in 2022 industry development prospect market investment analysis (the attachment is a link to the network disk, and the report
Functions and arrays of shell scripts
2022 recommended RCEP regional comprehensive economic partnership agreement market quotation Investment Analysis Industry Research Report (the attachment is a link to the online disk, and the report i