Basic Data Types and Expressions of C Language

  1. Integer type:
    The data of integer type is integer data, and the value without fractional part.
    Basic type: int
    Short integer type: short [int]
    Long integer type: long[int]
    Unsigned type: unsigned int , unsigned short , unsigned long
  2. Real number type:
    The data of the real number type is real data, also known as floating-point data (ie decimals) in C language.
    Single-precision type: float
    Double-precision type: double
    Floating-point data in C language has the following two forms of expression:
    (1) The decimal form is composed of positive and negative signs, numbers and decimal points. Such as: 153, -32, -1.45, 8.2
    (2) Exponential forms such as 32E+4, 32e+4 or 32E4, 32e4 all represent 32*10^4
    Note: There must be a number before the letter E or e, and after E or e The exponent of must be an integer.
    For example: legal exponent forms: 3.2E8, 4.5E-3, -4E-2, -3E+6
    illegal exponent forms: E8, 3E+2.4, 4.3E3.6, 8E, 6e
  3. Character type:
    character type data is character data, which can be divided into two types of expression: character and character string.
    (1) Character: A character enclosed in single quotation marks. Such as: 'A' , 'D' , 'a' , 's' , '!' , ' * ' , '#' Note
    : 'a' and 'A' are different characters.
    A character or a sequence of numbers preceded by a backslash (\) can also indicate a character quantity.
    The character led by the backslash (\) is called an escape character, which means that the character after the backslash (\) is transformed into another meaning.
    The n letter n in \n does not represent the letter n but the "newline" character. This escape character is called a special character.
    For example: '\101' represents the character 'A' (octal ASCII code)
    '\x41' also represents the character 'A' (hexadecimal ASCII code)
    '\ddd' represents the character represented by 1~3 octal . For example: '\012' represents a newline character, namely '\n'.
    Calculation method: 0* 8^2 + 1* 8^1 +2* 8^0=10 Refer to the ASCII code table to know that '\n' '\xhh' represents the character represented by
    1~2 hexadecimal. For example: '\x51' means the letter 'Q'
    Calculation method: 5* 16^1 +1*16^0=81 Refer to the ASCII code table to know the letter 'Q'
    (2) String: use a pair of double quotation marks to expand sequence of characters. Such as: "ASDFGH", "asdf", "XCSFhjid", "hello world"
    Note: 'a' is different from "A", characters are used for assignable values, strings are used for non-assignable values, such as: a= 'c' is correct, a="c" is wrong.

Guess you like

Origin blog.csdn.net/weixin_74837727/article/details/128151496