Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
fread returns more than i want
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Eric Sosman, post: 2438998"] You get a different interpretation if you regard buf as a zero-terminated string than if you regard it as an array of nread characters. In particular, if buf lacks a zero terminator it is not a proper string, and passing it to fprintf() invokes undefined behavior. (A likely result is that fprintf() will "run off the end" of buf until it stumbles upon a zero byte somewhere else in memory; you are probably seeing the characters that precede that zero.) Also, if '%' appears anywhere in buf, fprintf() will try to interpret it as a formatting directive ... Your best bet is to use fwrite(), as you apparently intend to do eventually in any case. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
fread returns more than i want
Top