Subject: Re: comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Approved: clc@plethora.net References: <1999Apr01.0303.scs.0004@eskimo.com> From: seebs@plethora.net (Peter Seebach) X-Newsreader: trn 4.0-test70 (17 January 1999) Organization: Plethora . Net - More net, less spam! Lines: 80 Newsgroups: comp.lang.c,comp.lang.c.moderated,alt.comp.lang.learn.c-c++,comp.answers,alt.answers,news.answers Message-Id: In article <1999Apr01.0303.scs.0004@eskimo.com>, Steve Summit wrote: >3.4: Don't precedence and parentheses dictate order of evaluation? >A: Operator precedence and explicit parentheses impose only a > partial ordering on the evaluation of an expression, which does > not generally include the order of side effects. This isn't true. In _C: The Complete Reference_, by Herbert Schildt (who has sold a hell of a lot more books than *you* have, my friend), Herb points out that, while x = *p++ * (*p); will not set x to (*p) squared, x = *p * (*p++); will. Expressions evaluate right to left in C. >3.8: What's a "sequence point"? >A: A point (at the end of a full expression, or at the ||, &&, ?:, > or comma operators, or just before a function call) at which all > side effects are guaranteed to be complete. This is a made-up term used only in this FAQ; there isn't even an index entry for "sequence point" in C:TCR. >6.21: Why doesn't sizeof properly report the size of an array which is > a parameter to a function? >A: The sizeof operator reports the size of the pointer parameter > which the function actually receives. Wrong! C:TCR, p. 53, shows that sizeof gives the size of the array. >11.12b: Can I declare main() as void, to shut off these annoying "main > returns no value" messages? >A: No. I don't see why you're saying this; in C:TCR, page 163, it's made clear that you can do this. >12.1: What's wrong with the code "char c; while((c = getchar()) != > EOF) ..."? >A: The variable to hold getchar's return value must be an int. This is not true. The problem is, since getchar() returns an int, and EOF is a valid integer value, you still need to check 'feof'. >12.26: Will fflush(stdin) flush unread characters from the standard > input stream? >A: No. Where do you get this crap? C:TCR, p. 298: If /stream/ points to an input file, the contents of the input buffer are cleared. >14.1: When I set a float variable to 3.1, why is printf printing it as > 3.0999999? >A: Most computers use base 2 for floating-point numbers, and many > fractions (including 0.1 decimal) are not exactly representable > in base 2. This is a poor answer; you should point out that it generally won't happen if you declare the variable as double. Overall, it's quite clear that you have a lot to learn from Mr. Schildt. What a maroon. -s -- Copyright 1999, All rights reserved. Peter Seebach / seebs@plethora.net C/Unix wizard, Pro-commerce radical, Spam fighter. Boycott Spamazon! Will work for interesting hardware. http://www.plethora.net/~seebs/ Visit my new ISP --- More Net, Less Spam!