views:

97

answers:

3

Hi , 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 ?

+2  A: 

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

roe
+1  A: 

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

avakar
+5  A: 

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

Carl Smotricz