Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: [File Handling] fread(), fseek() and text file |
| Date | 2016-12-17 12:22 -0800 |
| Organization | None to speak of |
| Message-ID | <lnr356i9vg.fsf@kst-u.example.com> (permalink) |
| References | (8 earlier) <bb0da670-4df4-4db4-a023-bac9f68b039d@googlegroups.com> <o31cc7$4gs$1@dont-email.me> <8d806f76-16d7-4a2d-835e-4a75e4e32fd5@googlegroups.com> <6oqa5c5r18v04ebmilodlbh2pp6f8bcsn8@4ax.com> <e479571a-ed94-4c01-9f3e-0494640df7f1@googlegroups.com> |
Dexterr <dejangru@gmail.com> 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 <stdbool.h>), 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 <http://www.ghoti.net/~kst>
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"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-16 01:10 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 09:59 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-16 05:28 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 14:02 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-16 06:30 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 15:20 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-16 08:54 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 17:00 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-16 09:32 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 17:38 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-16 10:03 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 18:40 +0000
Re: [File Handling] fread(), fseek() and text file Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-16 20:16 +0000
Re: [File Handling] fread(), fseek() and text file Keith Thompson <kst-u@mib.org> - 2016-12-16 12:46 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-17 05:47 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-17 05:49 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-17 05:43 -0800
Re: [File Handling] fread(), fseek() and text file Barry Schwarz <schwarzb@dqel.com> - 2016-12-17 08:48 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-17 12:03 -0800
Re: [File Handling] fread(), fseek() and text file Keith Thompson <kst-u@mib.org> - 2016-12-17 12:22 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-17 12:23 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-17 12:26 -0800
Re: [File Handling] fread(), fseek() and text file asetofsymbols@gmail.com - 2016-12-18 12:41 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-18 13:04 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-18 13:08 -0800
Re: [File Handling] fread(), fseek() and text file asetofsymbols@gmail.com - 2016-12-19 06:14 -0800
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-19 10:38 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-19 18:51 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-19 11:14 -0800
Re: [File Handling] fread(), fseek() and text file Richard Heathfield <rjh@cpax.org.uk> - 2016-12-19 19:35 +0000
Re: [File Handling] fread(), fseek() and text file Dexterr <dejangru@gmail.com> - 2016-12-19 10:43 -0800
csiph-web