什么会打印 - % - 30.4f [英] what will this print-%-30.4f
问题描述
i = 1234.5678;
printf(% - 30.4,i);
*这将打印什么 - % - 30.4f,在这个声明中是什么意思-30和如果它的+30和如果它的3等等*我知道它只是%.2f的含义它将只打印小数点后的2位数。
i=1234.5678;
printf("%-30.4",i);
*what will this print-%-30.4f ,in this statement whats the meaning of -30 and what if its +30 and what if its 3 etc. *I know the meaning if its just %.2f it will print only 2 digits after the decimal point.
推荐答案
这样的问题很容易找到答案。请先尝试为自己做一些基础研究。请参阅 https://msdn.microsoft.com/en-us/library/wc7014hz.aspx [ ^ ]。
Question like this are easy to find answers for. Please try and do at least some basic research for yourself first. See https://msdn.microsoft.com/en-us/library/wc7014hz.aspx[^].
i = 1234.5678;
i=1234.5678;
您是否使用 i 作为名称一个浮点变量以欺骗敌人? :-)
Do you use i as the name of a floating point variable in order to deceive the enemy? :-)
printf (%-30.4,i);
printf("%-30.4",i);
这是错误的:它缺少说明符
(参见printfat C ++ reference [ ^ ])。
你可能意味着
This is wrong: it lacks the specifier
(see "printf" at C++ reference[^]).
You probably meant
printf("%-30.4f",i);
这意味着(就像你一样)可能很容易找到你自己,理查德已经告诉你了):
- 在给定字段中左对齐(' - ')
- 字段总共使用30个字符
- 仅打印4位小数
- Left align in the given field ('-')
- Use a total of 30 characters for the field
- print only 4 decimal digits
That means (as you could have easy found yourself, Richard told you it already):
这篇关于什么会打印 - % - 30.4f的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!