Summary of C data types and c Data Types
Analogy is a good way to learn a new language. Let's look at the data types of C language in comparison with java.
The C language provides a wide range of data types. The following figure shows all the data types in the C language:
We can see that the C language provides struct, shared body, and pointer types not available in java, and the C language lacks the boolean Type in java, the difference between C language and java is also reflected in the number of digits occupied by each type. For details, see:
The following describes the precautions for various types of use.
1. Integer
There are three carry-in systems for Integer constants in C language: decimal, octal, and hexadecimal. In use, the decimal number starts with a non-0 number, the octal number starts with 0, the hexadecimal number starts with 0x, And the hexadecimal numbers can be converted to each other. For example, you can directlyPrintf ("% d", 0x567)
Other conversions, and so on.
2. Floating Point
If you want to use the float type, add f or F to the back of the number.
Floating-point constants can be expressed by exponent, and E is used to represent the base-10 power, for example, 1.23E4 = 1.23*10 ^ 4.
Under ExploitationPrintf ("% f", 1.23456)
For output, the default value is to retain the last six digits of the decimal point. If you want to set it yourself, you can use %. xf, where x indicates the number of digits you want to output, as shown inPrintf ("%. 3f", 1.2345)
The output is 1.235.
The floating point type is stored in the computer in two parts: the ending number and the index. The ending part indicates a valid number. The more the ending part, the more precise the number. The index determines the value range of a number. The larger the number of digits, the larger the value range. The valid numbers of float and double are as follows:
3. Balanced
In java, 16-bit Unicode encoding is used to store char-type values, while in C, 8-bit ASCII encoding is used for storage.
In C, escape with "\" as the escape character. The detailed escape character table is as follows:
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.