应用程序将数据收集到一个简单的格式化字符串中。
This application collects the data into a simply formatted string.
常见的格式化字符串攻击来自于一个思想:攻击者可以控制显示数据所使用的格式。
The often-serious format string attack is based on the idea that an attacker can control the format used to display data.
上面代码中的格式化字符串 %1$tB 告诉程序使用第一个参数并打印 date 对象的完整月名。
The %1$tB formatting string in the code above tells the program to use the first argument and print out the full month name for the date object.
You could absolutely implement something more interesting and something even more animated like we saw on Wednesday or even earlier today, but it takes a little more than just a format string.
你绝对可以实施一些更有用的,和一些更愉快的东西,像我们周三或今天早些时候,看到的,但它不只是,格式化字符串。
So the end result, because someone wrote this function years ago is that printf takes this thing, takes this thing, David plops David inside the middle of that formatted string and then renders the whole result.
基于这是某人多年以前写的程序,最终的结果是打印出这个,这个,在格式化字符串中间的,然后返回结果。
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.
看下这个底部,这个是相当随意的,但我选择把我的字符串格式化成这样:,所以在这个底部我打印输出,提醒一下,这是一个只打印出,小数点后一位的方法。
应用推荐