c#访问修饰符修饰无效
In this post I want to create a helpful reference for all the C conversion specifiers you can use, commonly with printf()
, scanf()
and similar I/O functions.
在本文中,我想为您可以使用的所有C转换说明符创建有用的参考,这些说明符通常与printf()
, scanf()
和类似的I / O函数一起使用。
Specifier | Meaning |
---|---|
%d / %i | Signed decimal integer |
%u | Unsigned decimal integer |
%c | Unsigned char |
%s | String |
%p | Pointer in hexadecimal form |
%o | Unsigned octal integer |
%x / %X | Unsigned hexadecimal number |
%e | Floating point number in exponential format in e notation |
%E | Floating point number in exponential format in E notation |
%f | double number in decimal format |
%g / %G | double number in decimal format or exponential format depending on the value |
说明符 | 含义 |
---|---|
%d / %i | 有符号十进制整数 |
%u | 无符号十进制整数 |
%c | 未签名的char |
%s | 串 |
%p | 十六进制形式的指针 |
%o | 无符号八进制整数 |
%x / %X | 无符号十六进制数 |
%e | 浮点数的指数格式e 符号 |
%E | E 表示法中指数格式的浮点数 |
%f | 十进制格式的double 精度数字 |
%g / %G | 取决于值的十进制格式或指数格式的double 数字 |
In addition to those specifiers, we have a set of modifiers.
除了这些说明符,我们还有一组修饰符 。
Let’s start with digits. Using a digit between %
and the format specifier, you can tell the minimum field width. Example: %3d
will take 3 spaces regardless of the number printed.
让我们从digits开始。 使用%
和格式说明符之间的数字,您可以知道最小字段宽度。 示例: %3d
将占用3个空格,而不管打印的数量如何。
This:
这个:
printf("%4d\n", 1);
printf("%4d\n", 12);
printf("%4d\n", 123);
printf("%4d\n", 1234);
should print
应该打印
1
12
123
1234
If you put a dot before the digit, you are not telling the precision: the number of decimal digits. This of course applies to decimal numbers. Example:
如果在数字前加点,则不会告诉精度:小数位数。 这当然适用于十进制数字。 例:
printf("%4.2f\n", 1.0);
printf("%4.3e\n", 12.232432442);
printf("%4.1e\n", 12.232432442);
printf("%4.1f\n", 123.22);
will print:
将打印:
1.00
1.223e+01
1.2e+01
123.2
In addition to digits, we have 3 special letters: h
, l
and L
.
除数字外,我们还有3个特殊字母: h
, l
和L
h
, used with integer numbers, indicates ashort int
(for example%hd
) or ashort unsigned int
(for example%hu
)与整数一起使用的
h
表示一个short int
(例如%hd
)或一个short unsigned int
(例如%hu
)l
, used with integer numbers, indicates along int
(for example%ld
) or a long unsigned int (for example%lu
).l
(与整数一起使用)表示long int
(例如%ld
)或long unsigned int(例如%lu
)。L
, used with floating point numbers, indicates along double
, for example%Lf
L
与浮点数一起使用,表示一个long double
%Lf
字符,例如%Lf
c#访问修饰符修饰无效