c#访问修饰符修饰无效_C转换说明符和修饰符

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函数一起使用。

SpecifierMeaning
%d / %iSigned decimal integer
%uUnsigned decimal integer
%cUnsigned char
%sString
%pPointer in hexadecimal form
%oUnsigned octal integer
%x / %XUnsigned hexadecimal number
%eFloating point number in exponential format in e notation
%EFloating point number in exponential format in E notation
%fdouble number in decimal format
%g / %Gdouble 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个特殊字母: hlL

  • h, used with integer numbers, indicates a short int (for example %hd) or a short unsigned int (for example %hu)

    与整数一起使用的h表示一个short int (例如%hd )或一个short unsigned int (例如%hu )

  • l, used with integer numbers, indicates a long 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 a long double, for example %Lf

    L与浮点数一起使用,表示一个long double %Lf字符,例如%Lf

翻译自: https://flaviocopes.com/c-conversion-specifiers/

c#访问修饰符修饰无效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值