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 ?
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 ?
It signifies a decimal number followed by a character
'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).
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".