Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: [File Handling] fread(), fseek() and text file Date: Sat, 17 Dec 2016 12:22:27 -0800 Organization: None to speak of Lines: 28 Message-ID: References: <1d89377e-acd5-47d7-abca-1a3d28b65678@googlegroups.com> <027c95a8-183b-4d34-8214-cdc41be578b6@googlegroups.com> <703f5537-45b1-4946-af97-3615c15dbbd3@googlegroups.com> <8d806f76-16d7-4a2d-835e-4a75e4e32fd5@googlegroups.com> <6oqa5c5r18v04ebmilodlbh2pp6f8bcsn8@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="e78518cb170f971596b310979c28ba23"; logging-data="3857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+y6rvDIw0eihlhDjc4Ib71" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Ubmi9XoSNYwzIsjP/ukIuQfwXvI= sha1:Dhw0dA9esMzHuvPVIQYCoOayjjc= Xref: csiph.com comp.lang.c:99767 Dexterr writes: [...] > int is_comment(const char *line); [...] > if(is_comment(line) == 0) The value returned by the is_comment function is logically Boolean. Starting with C99, you could use the built-in type _Bool (or bool if you have #include ), but it's still reasonable to use int, with zero for false and any non-zero value for true. The comparison operators ("==", "<", et al) still yield a result of type int with the value 0 or 1. Boolean values should rarely be compared for equality. Rather than if(is_comment(line) == 0) it would be much clearer to write: if (! is_comment(line)) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"