%dn 是格式字符串吗?
我最近在代码中遇到了这一行 -
fprintf(logfile," |-IP Version : %dn",(unsigned int)iph->version);
这里的“%dn”是格式字符串吗?如果是这样,这意味着什么?
I recently came across this line in a code -
fprintf(logfile," |-IP Version : %dn",(unsigned int)iph->version);
Is "%dn" here a format string ? If so , what does it signify ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来有点像有人想编写
%d\n
来用换行符终止该行,但反斜杠在某处丢失了。无论如何,格式代码都以“d”结尾。It sounds a bit like someone wanted to write
%d\n
to terminate the line with a linefeed, but the backslash got lost somewhere. The format code, in any case, ends with the "d".不,%d 是格式字符串,表示十进制值。将附加“n”。除非它是 '\n',它可能应该是,这是一个换行符(当然也会被附加)。
No, %d is a format string, signifying decimal value. 'n' will be appended. Unless it's '\n', which it probably is supposed to be, which is a newline (which will also be appended of course).
它表示一个十进制数,后跟一个字符
'n'
。It signifies a decimal number followed by a character
'n'
.