C language programming-data type

Programming specification
Code indentation
Variable and constant naming specification
Member variable
function naming specification
Comment
identifier
Definition: In order to use variables, constants, functions, arrays, etc. in the process of program operation, make a name for its form, called identifier
identification Rules for naming characters:
1. Must start with a letter or underscore
2. In addition to the beginning, there can be letters, underscores or numbers in other positions
3. The size of English letters represent different identifiers
4. Identifiers cannot be keywords
5. Identifier commands should have relevant meaning
. 6. Identifiers can be of any length.
C data type.
Basic type: numeric type character type.
Numerical type: integer, floating point
integer: short integer (short int 2 bytes) basic integer Type (int 4 bytes) Long integer type (long int 4 bytes)
Real type: Floating point type: Single precision (float) Double precision (double)
Character type
variable
Variable: Represents a certain value in computer memory The storage space can store different data
type identifiers-the type of the variable is declared, which determines the number of bytes of the memory unit allocated by the program for the variable, that is, the value range of the
variable. The naming rule for variable names: identifiers can only consist of numbers, It is composed of letters and underscores. The first
character must be a letter or underscore. The maximum number of valid characters is 31
Variable "initialization": After the variable is defined, the program allocates corresponding storage space for the variable in the memory. The empty data is stored at random. We need to re-assign the variable. This process is called the variable initialization
variable storage category
static storage : Allocate a fixed storage space for the program when it is running.
Dynamic storage: dynamically allocate storage space as needed during the running of the program.
Auto variable: Used to define a local variable as automatic. When the variable is executed, a new variable will be generated. , Re-initialize it
static variable: static variable
register variable: register storage class variable
extern variable: external storage variable
operator
Arithmetic operator: +-* /% ++-
relational operator:> <== >= <= !+
Logical operator: && ||!
Bit operator: >> << ~ | ^ /=
Assignment operator: = += -= = /=
Conditional operator:?:
Comma operator:,
byte operator :sizeof
pointer operator:
&
other operators: () [] (->,.)
operator precedence
Operator associativity:
operator's "
object ": construction type: array structure (struct) union (Union)
enumeration type (enum)
pointer type (*): pointer is the address
void type (void): used to define the function return value
Define the type (typedf)
constant
Constant: Constant is the value that cannot be changed during the running of the program
Numerical constant: Integer constant Real constant
Integer constant:
Long integer: Long integer is 32-bit, write integer Type constants can be modified by adding the symbol L or U after the constant.
Short integer:
signed integer:
unsigned integer: the value range is 0~65535
Character constant: character constant String constant
Character constant: Use '' means that only one character is case-sensitive.
String constant: Use "" to indicate multiple characters.
Escaping characters:
\n: carriage return and line feed
\f: horizontal jump to the next tab position
\v: vertical Tabs
\b: Backspace
\r: Carriage return
\f: Paper feed and page feed
\: Backslash "\"
': Single quote
\a: Bell
\ddd: Characters represented by 1~3 octal system
\ xhh: Characters represented by 1~2 hexadecimal
symbols Symbolic constants:
Numerical constants
Character constants
Symbolic constants
Real constants: consist of integer part and decimal part
Scientific notation: HardStudy1=123.45; HardStudy2=0.5555;/ scientific notation Law /
Exponential method: HardStudy 1=1.2345e2; HardStudy2=321.1e-1/ Exponential display /
Numerical data storage characteristics
1. Use binary storage
2. Use limited number of digits
3. Use complement to represent
data type
conversion principles: Convert the short data length to the long data length to ensure that the accuracy of the data does not decrease.
Assignment conversion: If the data types on both sides of the prefects are different, the type on the right side of the assignment operator is converted to the type
coercive type conversion of the variable on the left : Use type conversion operators to force a certain data or expression to be converted to a specific type.
Data length rules (from large to small)
long double
double
float
long int
int
short int
char

Guess you like

Origin blog.csdn.net/weixin_45743004/article/details/103705961