I have come across some legacy code that has the following type of line:
sscanf(szBuff,\"%Fd %Ff %Fd %Ff\"
Has anyone seeen a modifier like Fd or Ff? If so, wha
As ouah pointed out, these are the same as their lower case counterparts. Why is that? For symmetry with the printf conversion specifiers. Here %x
and %X
write lowercase or uppercase numbers like deadbeef
and DEADBEEF
. The symmetry allows to use the same format string for both input with scanf
and output with printf
.
#define FMT "%F\n"
sscanf (str, FMT, &value);
printf (FMT, value);
%F
is a POSIX (and C99) extension.
http://pubs.opengroup.org/onlinepubs/007904975/functions/scanf.html
"The conversion specifiers A, E, F, G, and X are also valid and shall be equivalent to a, e, f, g, and x, respectively."
C says for fscanf
functions:
(C991, 7.19.6.2p14) The conversion specifiers A, E, F, G, and X are also valid and behave the same as, respectively, a, e, f, g, and x.
So in %Fd
, the conversion specification is %F
which is equivalent to %f
. Note that the d
is not part of the conversion specification.
For example (for fprintf
functions %F
is also the same as %f
):
printf("%fd\n", 3.141592);
will print:
3.141592d
F
conversion specifier. For example, for fscanf
the corresponding C90 paragraph in 7.9.6.2 says: The conversion specifiers E, G, and X are also valid and behave the same as, respectively e, g, and x