Is %dn a format string?

℡╲_俬逩灬. 提交于 2020-01-07 06:43:51

问题


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 ?


回答1:


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".




回答2:


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).




回答3:


It signifies a decimal number followed by a character 'n'.



来源:https://stackoverflow.com/questions/2037760/is-dn-a-format-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!