what mean this part of the printf
there is %05.5fCode:%05.5f, "
and there is a space after a comma
what this thing does?
Look up format specifiers in your textbook, there under printf. Everything else in the quotes just gets printed normally. (The last quote is just the end of your quotes.)
f Decimal floating point
0 Left-pads the number with zeroes (0) instead of spaces, where padding is specified (see width sub-specifier).
(number) Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger.
.number For e, E and f specifiers: this is the number of digits to be printed after the decimal point.
Here's a tip, when somebody does get some advice wrong, there will probably someone posting to to correct them fairly promptly.
If a post has gone unchallenged for a while, and is even backed up by someone else, it's a pretty safe bet that it's correct.
If you suspect some advice was incorrect, just ask for someone else to confirm.
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
so the first 5 means that we need to print at least five chars in this float number
and the second 5 means to print the float number in persition 5 place after the point
Read it again:
There will be five digits printed after the decimal point..number For e, E and f specifiers: this is the number of digits to be printed after the decimal point.
it says there
but in my printf i get the flag at the last place
Eh? Your flag was 0, your width was 5, your precision was 5, you didn't have a length, and your specifier was f.
can you rephrase this line
"0 Left-pads the number with zeroes (0) instead of spaces, where padding is specified (see width sub-specifier)."
i cant understand the meaning of this padding thing
If we use %d as an example:
would produce the output of:Code:printf("%5d\n", 123); printf("%05d\n", 123);
So in the first example, it gives you spaces to make a length of five, in the second case, it uses 0 to fill the length.Code:123 00123
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
so when there is no char between the % and 5
it put blank spaces?