Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Comparing chars to constants Message-ID: <8792@utzoo.UUCP> Date: Mon, 19-Oct-87 16:11:15 EDT Article-I.D.: utzoo.8792 Posted: Mon Oct 19 16:11:15 1987 Date-Received: Mon, 19-Oct-87 16:11:15 EDT References: <4663@elroy.Jpl.Nasa.Gov>, <31174@sun.uucp> Organization: U of Toronto Zoology Lines: 17 > ... Alternatively, you can write > > if (p == '\200') That's what I would do. I find that such problems are largely avoided, and (in my opinion) the code is clearer, if one treats char as a distinct type and intermixes it with ints only in certain situations (e.g. using an int to hold a char value or EOF). Following that rule, when one wants to compare a char to a constant, one uses a char constant, not an int constant. (Yes, I look for a string terminator as '\0', not 0.) For those barbarous folk who prefer hexadecimal to octal (God clearly meant man to use octal, the thumbs are parity bits), X3J11 has added hex string escapes. -- "Mir" means "peace", as in | Henry Spencer @ U of Toronto Zoology "the war is over; we've won". | {allegra,ihnp4,decvax,utai}!utzoo!henry