Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to represent characters, numbers, dates and logical constants?
How to represent characters, numbers, dates and logical constants?
Character type: const char

Value: const int/double/ etc.

There is no date of this type, but the date can actually be represented by long int, and then the date in print format is passed.

Logic is actually an integer, Boolean.

Extended data:

In C language, there are only four basic data types-integer, floating point, pointer and aggregate (such as array and structure).

1. integer

Integer family includes characters, short integers, integers and long integers. It can be divided into signed version and unsigned version. I often use characters (char) and integers (int). Integer in the title refers to a data type, which means integer in Chinese, that is, only integers can be saved. Integer (int) in integer family refers to the keyword of C language. Minimum range type of variables Minimum range signed char- 128 ~ 127 unsigned char 0 ~ 255 signed int-32767 ~ 32768 unsigned int 0 ~ 65535 in C language. Whether char is a signed char or an unsigned char depends on the compiler. In general, char defaults to signed char.

1. 1 integer constant (text)

Integer constants can also be called integer literals.

Integer constants can be assigned in binary, octal, decimal and hexadecimal. Where binary starts with 0b, octal starts with 0, and the default is decimal, and hexadecimal starts with 0x. For example, it means decimal number 16, binary number 0b11111,octal number 020 and hexadecimal number 0xFF. Hexadecimal English letters can be uppercase or lowercase. Adding the character L or L (letter L) after the integer constant can make this integer multiple be interpreted as a long integer value, and the character U or U can be specified as an unsigned integer value. Character constant. A character constant is a single character (or a character escape sequence or a three-letter word) enclosed in single quotation marks, and its type is always int. Such as' m' and' n'

1.2 enumeration type An enumeration type refers to a type whose value is a symbolic constant instead of a literal value.

2. Floating-point type

The floating-point number series includes float, double and long double types.

The ANSI standard specifies a minimum range: all floating-point types can hold at least any value between 10 -37 and 10 37.

Similarly, floating-point constants are all double types by default, which can be followed by l or l to indicate that it is a long double type, or by f or f to indicate a float type.

3. Pointer

Variable values are stored in the memory of the computer, and each variable occupies a specific position. The value of the pointer variable is another memory address.

3. 1 pointer constant It is almost useless to express pointer constants as numerical constants, so there is no specific definition of this concept in C language.

3.2 string text

A string is a string of zero or more characters at the end of the NUL byte.

Strings are usually stored in character arrays, which is why there is no explicit string type in C language. NUL bytes cannot be included in a string because they are used to terminate the string. NUL was chosen as the terminator of the string because it is not a printable character.