又如果想要为特定的某种信息提供定制的输出格式化,又该怎样呢?
What if you want to provide custom output formatting for a particular type of information?
函数的作用是:输出格式化字符串到流(例如:文件或数据库)。
The vfprintf() function writes a formatted string to a specified output stream (example: file or database).
第一个运算对象也就是说明格式的字符串,包含一个或者更多的格式序列,规定了第二个运算对象的输出格式。返回的结果就是格式化后的字符串了。
The first operand is the format string, which contains one or more format sequences, which specify how the second operand is formatted. The result is a string.
Glancing at the bottom, this is pretty arbitrary, but I chose to format my string as follows: % 1f so at the bottom here I'm printing out %.1f, which quick sanity check means print just one digit after the decimal place.
看下这个底部,这个是相当随意的,但我选择把我的字符串格式化成这样:,所以在这个底部我打印输出,提醒一下,这是一个只打印出,小数点后一位的方法。
But if you avoid all of these minutia and focus really just on the idea, it looks like what was a blue say block, a so called statement, is now going to be something called printf where the F happens to stand for formatted.
但是如果你抛开所有这些繁琐的细节,把注意力集中到,它的编程思想,那么它只不过一个蓝色的say程序块,是一个声明,即所谓的printf函数,其中的f是,用于格式化输出。
Well, here is the F in printf for formatted printing.
这里printf中的f是用于格式化输出的。
应用推荐