The compiler gives you the error "too many parameters for printf" because it doesn't recognize %F
as a format specifier.... so the parameter you have added to printf()
is extra, and should not be there.
The standard format specifiers from C89 below, specify that the floating point formats are e
, E
, f
, g
and G
(does not include F
, the reason is stated in the last edit of this answer)
Remember that the compiler shouldn't read the format string of printf()
at all to match the parameters with the format specifiers, so what is happening there should only deal with the printf(3)
specification, and that is indeed an issue for printf(3)
not for the compiler. Probably if you try the generated program it should work.
EDIT
I have tried on clang (sorry, but I have no gcc here) and I have discovered some possible cause of the issue (not an error, either). The printf(3)
implementation here, does never switch to scientific notation at all (which is something I have not checked with the standard) so it is never going to generate an alphabetic character and no lowercase or uppercase letter is concerned. So for the program
#include <stdio.h>
int main()
{
printf("%5.3G\n", 3.141592654E160);
}
it prints:
$ ./a.out
3.14E+160
$ _
while for
#include <stdio.h>
int main()
{
printf("%5.3F\n", 3.141592654E160);
}
it prints
$ a.out
31415926539999999255132844331312943389972993386142531366742209094398699375217155068328829400434148008839629239544769533043070670437328460352417427610347451187200.000
$ _
As only digits and decimal point are emitted, there's no uppercase or lowercase interpretation on the case of the format specifier, making both forms equivalent (but one being nonstandard).
The solution is just to switch to lowercase f
.
As @chux-ReinstateMonica suggests in one of the comments, C89, page 133 (143 of the pdf), the standard doesn't include the F
format specifier, only e
, E
, f
, g
and G
. This should be normal, considering that f
never changes to exponential notation.