Environment: DEV-C 4.9.6.0 (GCC / MINGW32), use -wall compile options
Basic types include byte type (CHAR), integer (int), and float / double). When defining basic type variables, you can use symbol attributes signed, unsigned (for char, int), and length properties short, long
The value of the variable is described in int, double.
The base type and value range of the basic type under DEV-C is listed below:
Symbol Property Length Property Basic Placeholder Venue Range Enterprise Example Output
- - CHAR 8 -2 ^ 7 ~ 2 ^ 7-1% C% C,% D,% usigned - char 8 -2 ^ 7 ~ 2 ^ 7-1% C% C,% D,% uunsigned - Char 8 0 ~ 2 ^ 8-1% C% C,% D,% U
[SIGNED] SHORT [INT] 16 -2 ^ 15 ~ 2 ^ 15-1% HDunsigned Short [INT] 16 0 ~ 2 ^ 16-1% Hu,% HO,% HX
[Signed] - INT 32-2 ^ 31 ~ 2 ^ 31-1% Dunsigned - [INT] 32 0 ~ 2 ^ 32-1% U,% O,% X
[Signed] long [int] 32 -2 ^ 31 ~ 2 ^ 31-1% ldunsigned long [int] 32 0 ~ 2 ^ 32-1% lu,% lo,% lx
[Signed] Long Long [INT] 64 -2 ^ 63 ~ 2 ^ 63-1% i64dunsigned long long [int] 64 0 ~ 2 ^ 64-1% i64u,% i64o,% i64x
- FLOAT 32 /- 3.40282E 038% f,% E,% g - Double 64 /- 1.79769E 308% LF,% Le,% lg% F,% E,% G - Long Double 96 /- 1.79769E 308% LF,% Le,% LG
Some explanations:
1. Note! Every line in the table represents a basic type. "[]" Represents it can be omitted. For example: char, sign char, unsigned char is three different types of mutually different types; int, short, long is also three types of different types. You can use C function overload characteristics to verify, such as: Void Func (CHAR CH) {} Void Func (unsigned char ch) {} is three different functions. 2. CHAR / SIGNED CHAR / UNSIGNED CHAR Type Data is 1 byte; char is a symbolic type, but it is different from Signed Char. Note! Not all compilers are handled in this way, the length of the CHAR type is not necessarily 1 byte, and the char is not necessarily a symbolic type.
3. When converting char / signed char to int, the highest symbol bit 1 is extended to cause operational issues. Therefore, if there is a case where the byte value is greater than 127 in the data to be processed, use unsigned char. If the bit is involved in the program, you should also use the unsigned variable.
4. When char / sign char / unsigned, the formatter% c (according to the character mode) is used; or use% D,% U,% X /% X,% O, according to the integer mode, when input, should be used % C, if an integer method is used, DEV-C gives a warning, which is not recommended.
5. The length of int is 16 or 32, which is related to the compiler word. Under the 16-bit compiler (such as the compiler used by TC), int is 16 bits; 32-bit compiler (such as compiler cl.exe used by VC), int is 32
Bit.
6. Integer data can input the output using% D (Symbol 10),% O (no symbol 8) or% x /% X (no symbol 16). The format is% U, indicating that unsigned, ie unsigned 10 encompasses.
7. Integer prefix h represents Short, L represents long. When entering the output Short / Unsigned Short, it is not recommended to use the INT format% D /% u et al., Add the prefix h. This habitual error comes from TC. Under the TC, the length and default symbol attribute of int is consistent with Short, so the two types are used as the same, and the input and output is performed in an int mode.
8. Enter output: "% LLD" and "% llu" in Linux are formatters for the long long int type (64 bits) input and output under Linux. The "% i64D" and "% i64u" are formatted by Microsoft VC reservoirs for inputting output __int64 types. The compiler used by DEV-C is MINGW32, MINGW32 is one of the X86-Win32 GCC sub-projects, the compiler core or the GCC under Linux. The function parameter type check is checked in the compile stage, the GCC compiler checks the format string, apparent that it does not recognize "% i64D", so a warning "Unknown Conversion Type Character` I 'in format "will be given. For "% LLD" and "% llu", GCC is underway. MINGW32 uses GCC rules to check syntax during compilation, but uses the Microsoft library when connecting and running. The Printf and Scanf functions in this library do not know "% LLD" and "% llu" under Linux GCC, but "% i64D" and "% i64u" are it.
Enjoy and work properly.
9.% F,% E /% E or% G /% G, and Scanf will be automatically processed according to the input data. You can use% F (normal way),% e /% e (index mode) or% g /% g (automatic selection) when output.
10. Rules of floating point parameters stack: Float (4 bytes) type extends into a Double (8 bytes). So when entering, you need to distinguish FLOAT (% F) and Double (% LF), and when output, by% f. The PRINTF function outputs Float (extended to double) and Double data that are pressed into the stack according to the Double type rule. If the% LF format is specified when the output is output, the GCC / MingW32 compiler will give a warning.
11. DEV-C (GCC / MingW32) can select FLOAT length, whether it is consistent with DOUBLE.
12. Prefix L represents long (double). Although the long double is 4 bytes longer than the Double, the value range is the same. Long Double type of length, accuracy and representation are related to the compiler, operating system, and the like used.
These are tally according to some information on the Internet and their own opinions. Among them, there must be many mistakes, please correct it.