c++.command-line - printf
- Arthur Buse (14/14) Jun 17 2002 The page for stdio of the Runtime Library Reference,
- Jan Knepper (5/10) Jun 17 2002 Yes I would think that is a mistake.
-
Arthur Buse
(22/32)
Jun 17 2002
Ah, you are too busy to compile and run.
- Walter (4/19) Jun 18 2002 Actually, the text was translated from pdf format, and the automatic
The page for stdio of the Runtime Library Reference, http://www.digitalmars.com/rtl/stdio.html#fread the "Example for fread" contains the line printf ("Data read\n %. 256s", buf); Is that space between the . and 256 a mistake? Nothing is printed. The example below also does not print the string. If the space after . is removed, it works. (Real email address is zathras at freeuk dot com ) #include <stdio.h> main() { char buf[]="Hello, world!"; printf("\nbuf contains: %. 13s", buf); }
Jun 17 2002
Arthur Buse wrote:The page for stdio of the Runtime Library Reference, http://www.digitalmars.com/rtl/stdio.html#fread the "Example for fread" contains the line printf ("Data read\n %. 256s", buf); Is that space between the . and 256 a mistake?Yes I would think that is a mistake. The format string should be "%256s" Jan
Jun 17 2002
On Mon, 17 Jun 2002 13:37:00 -0400, Jan Knepper <jan smartsoft.cc> wrote:Arthur Buse wrote:Ah, you are too busy to compile and run. <grin> The buffer is 256 chars and is probably not \0 terminated, just the first 256 chars from some file. "%256s" pads the field with spaces. "%.256s" limits it to 256 chars. Sorry to go on about this, but people like me are trying to learn from the Runtime Library Reference. #include <stdio.h> main() { char buf[]="Hello, world!"; printf("\nfirst 5 chars of buf: %.5s", buf); printf("\nbuf padded to 20 chars: %20s", buf); } Output: first 5 chars of buf: Hello buf padded to 20 chars: Hello, world! Arthur. -- Windows 95 for Dummies, Windows ME for the Clinicaly Insane.The page for stdio of the Runtime Library Reference, http://www.digitalmars.com/rtl/stdio.html#fread the "Example for fread" contains the line printf ("Data read\n %. 256s", buf); Is that space between the . and 256 a mistake?Yes I would think that is a mistake. The format string should be "%256s"
Jun 17 2002
"Arthur Buse" <zathris hotmail.com> wrote in message news:qdmsgukdb92rardnidfm57tbl8hcbn1l3q 4ax.com...On Mon, 17 Jun 2002 13:37:00 -0400, Jan Knepper <jan smartsoft.cc> wrote:Actually, the text was translated from pdf format, and the automatic translator inserts random spaces in the output.Arthur Buse wrote:Ah, you are too busy to compile and run. <grin>The page for stdio of the Runtime Library Reference, http://www.digitalmars.com/rtl/stdio.html#fread the "Example for fread" contains the line printf ("Data read\n %. 256s", buf); Is that space between the . and 256 a mistake?Yes I would think that is a mistake. The format string should be "%256s"
Jun 18 2002