Summary: | no example on printf precision --- manual subsection "12.12.6 Other Output Conversions" | ||
---|---|---|---|
Product: | glibc | Reporter: | R N Alx <lascania> |
Component: | manual | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | enhancement | CC: | aj, ldv, mtk.manpages, roland |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | unspecified | ||
Target Milestone: | --- | ||
URL: | http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html#Other-Output-Conversions | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
.GIF picture of the manual page with wrong printf() example
.GIF picture with correct output conversion arguments printf() example |
printf ("%.3s%-.6s", "no", "where") does not produce " nowhere ". Mr Schwab, This example code, is not my own, not-my-own example ! printf ("%3s%-6s", "no", "where") this example is writen in the manual, it is writen wrong inside the online manual. I filled this bug because I want the online manual subsection "12.12.6 Other Output Conversions" to be changed because of two reasons: 1. reason one there are missing two dots, %3.s and %-.6s 2. reason two printf ("%.3s%-.6s", "no", "where") does YES YES YES produce " nowhere ". but not because of the output conversion arguments .3 and -.6, but because these two strings are only two characters and five characters long, thus the output conversion arguments .3 and -.6 have no influence but if the online manual is changed to: printf ("%.3s%-.6s", "noOoO", "whereEeEeEeE") the result will be " noOwhereE " which is what the online manual is trying to explain how printf() is using output conversion arguments to cut strings CHECK THE .GIF IMAGE http://sourceware.org/bugzilla/attachment.cgi?id=6678 CHECK THE ONLINE MANUAL http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html#Other-Output-Conversions Thanx printf ("%.3s%-.6s", "no", "where") does not produce " nowhere ", neither does printf ("%.3s%-.6s", "noOoO", "whereEeEeEeE") produce " noOwhereE ". You need a field width bigger than the precision to get any padding. Created attachment 6679 [details]
.GIF picture with correct output conversion arguments printf() example
Sir, I'm sorry but you are mistaken. Please see the image, to see confirmation. http://sourceware.org/bugzilla/attachment.cgi?id=6679 Please modify the online manual to contain valid information !!! Just a question: Shouldn't the manual say "field width" instead of precision? This is an example of a field of with 3: printf ("%3s",...) (In reply to comment #6) > Just a question: Shouldn't the manual say "field width" instead of precision? > > This is an example of a field of with 3: > printf ("%3s",...) Your example is wrong, because you must put a dot before three, .3, if you want to printf() only the first three3 characters of a string ! The manual should say something like, "to output less than the width of a string use the precision option .n to output only first n characters from a string". Regarding numbers, the manual should continue use precision. This example has nothing to do with field width or precision, it is about alignment (which is useless without a field width). Mr Schwab You said, printf ("%.3s%-.6s", "no", "where") does not produce " nowhere " You said, printf ("%.3s%-.6s", "noOoO", "whereEeEeEeE") does not produce " noOwhereE " THEY BOTH PRODUCE, " nowhere " RESPECTIVELY " noOwhereE " Are you able too see pictures on your computer, or are you still using an old text-screen terminal ? My bug is about R N Alx 2012-10-10 10:28:12 UTC http://sourceware.org/bugzilla/show_bug.cgi?id=14695#c2 If you do not understand, please let other people have a look at the images, and decide on this subject ! Do no longer stamp my bug as RESOLVED INVALID ! Thank You Sir ! printf ("%.3s%-.6s", "no", "where") produces "nowhere" and printf ("%.3s%-.6s", "noOoO", "whereEeEeEeE") produces "noOwhereE". COMPARE http://sourceware.org/bugzilla/show_bug.cgi?id=14695#c3 http://sourceware.org/bugzilla/show_bug.cgi?id=14695#c10 dude Schwab, just stay away ! keep distance, let somebody else look at the issue, not you ! take a walk in nature, clean your mind ! STAY AWAY !!!!!!!!! Stop reopening. Nothing what you wrote is true. R NH Alx, we resolve conflicts in a friendly manner. Stop insulting Andreas Schwab. It's fine to disagree on a technical level - but then you have to accept that Andreas is an expert in this area and disagrees with you. I do not care what flavour of expert is Andreas Schwab. My physics teacher always tells me that the laws of physics are based only on experiments and nobody with great authority can impose a law only because he has greater authority ! In comment #3 and in comment #10, Andreas Schwab, contradicts himself, this makes me believe that he has limited knowledge on the subject. Question: Can you folks view .GIF images on your computer screens ? I want to output only 5characters from a 10character string char str[] = "0123456789" Which printf() call will do that job ? I. printf("%5s", str) or II. printf("%.5s", str) Now lets see how big experts you are. This is not the point of the example. Read comment 8 again. (In reply to comment #8) > This example has nothing to do with field width or precision, it is about > alignment (which is useless without a field width). The reporter seems to be confused by the fact that this example demonstrates alignment while the text right before it talks about precision and there is no example on precision. The last sentence before the example explicitly talks about the - flag. Alright ! Then take 2 minutes of your time and include an example on precision ! printf("%.5s", "0123456789") produces: ‘01234’ Change the example about aligment from: printf ("%3s%-6s", "no", "where"); change it to: printf ("%10s(always)", "ON"); printf("\n"); printf ("%-10s(never)", "OFF"); produces: ‘ ON(always)’ newline ‘OFF (never)’ And now you may stamp the bug as solved. |
Created attachment 6678 [details] .GIF picture of the manual page with wrong printf() example glibc manual chapter "12. I/O on Streams" section "12.12 Formatted Output" subsection "12.12.6 Other Output Conversions" contains the following example line: "printf ("%3s%-6s", "no", "where");" this example is incorrect because there are two missing dots that are used to specify the precision of the output, how may characters printf() outputs. The correct version is: "printf ("%.3s%-.6s", "no", "where");" observe the dot inside %.3s and the second dot inside %-.6s ! Check the attached .gif image for better clarification !