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
Printing the last item of a structure twice
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="Keith Thompson, post: 3911172"] The above was written by RjY <RjY@sp.am>. Rafael, please don't delete attribution lines for quoted text. And please don't top-post. See the following for more information: [URL]http://www.caliburn.nl/topposting.html[/URL] [URL]http://www.cpax.org.uk/prg/writings/topposting.php[/URL] Yes, it does, and your revised code is valid, but I fail to see how it's better style. For one thing, just because C allows you to omit an explicit comparison doesn't mean it's a good idea. Opinions differ on this, but personally I prefer to use an explicit comparison unless the value being tested is "boolean". The value returned by fread is a count, not a true/false status, so I find an explicit comparison clearer. Second, you've changed the meaning of the code. This: fread(...) is true if fread returns any non-zero value, whereas this: fread(...) == 1 is true only if fread returns 1. As it happens, fread with the value 1 as its third argument can only return 1, so it doesn't matter in this case. But consider what would happen if, rather than fread, you were using fscanf, which can return either the number of items scanned (possibly 0) or EOF. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Printing the last item of a structure twice
Top