📄 c-iaq-a.html
字号:
which I moderate. (Steve Summit, the author of the original FAQ, is one of my co-moderators) Emily Postnews is the (fictional) author of a delightful guide to netiquette; no one listens to her (which may be just as well, as all of her advice is intended to be taken as sarcasm). <H3><A NAME="section-5"></A>Section 5: Arrays and Pointers</H3> <H4><A NAME="question-5.1"></A>5.1, 5.2</H4> <P>This is just a parody of the question about "<CODE>char *a</CODE>" and "<CODE>char a[6]</CODE>" in the real FAQ; of course, the two declarations are incompatible.</P> <H4><A NAME="question-5.4"></A>5.4</H4> <P>In fact, the reason typically given is that arrays aren't really quite objects in C, and they're often described as "second-class objects". The reference to Marxism is irrelevant, at best.</P> <H4><A NAME="question-5.5"></A>5.5</H4> <P>When I started annotating this, this was question 5.6; I have no idea what happened to 5.5. Anyway, the material is, of course, a joke. The real reason is that the function's parameter is a pointer, not an array; this looks silly, but it's how the language was built.</P> <H4><A NAME="question-5.6"></A>5.6</H4> <P>In other words, "some people will say anything". </P> <H4><A NAME="question-5.8"></A>5.8</H4> <P>First, a joke about the surprisingly limited character set (yes, 'f' really is in the standard minimum character set), then a remark about the non-existant, but often described, "equivalence" of arrays and pointers. The "equivalence" is that, since "<CODE>i[a]</CODE>" really means "<CODE>*(a+i)</CODE>", and addition is commutative, this is equivalent to "<CODE>*(i+a)</CODE>", which could also be spelled "<CODE>a[i]</CODE>".</P> <H4><A NAME="question-5.9"></A>5.9</H4> <P>The code provided does, in fact, "read" the numbers zero through 99 into the array. The expression "<CODE>(scanf, ("%d", i))</CODE>" is really an abuse of the comma operator; the values of the string literal, and of the name "<CODE>scanf</CODE>" (which, since it's not a function call, decays into a pointer to the function of the same name) are discarded, so really, this is just a loop of <CODE>"a[i] = i</CODE>". The reason to include <CODE><stdio.h></CODE> is that, without it, there will be no prototype for <CODE>scanf</CODE> in scope, and that will make the reference to the name invalid.</P> <H3><A NAME="section-6"></A>Section 6: Memory Allocation</H3> <H4><A NAME="question-6.1"></A>6.1</H4><P>Of course, even if the semicolon weren't missing, it still wouldn't work, because no space is allocated for the data stored by gets, and even if it were, gets would be able to overrun that space.</P> <H4><A NAME="question-6.3"></A>6.3</H4> <P>This is nonsense, of course; the casts are historical from when <code>char *</code> was the closest thing C had to a generic pointer type.</P> <H4><A NAME="question-6.5"></A>6.5</H4> <P>Part of the joke is swapping <em>nybbles</em>, when endianness normally affects the order of bytes within larger words.</P> <H3><A NAME="section-7"></A>Section 7: Characters and Strings</H3> <H4><A NAME="question-7.1"></A>7.1</H4> <p>One of the complicated tricks would be writing "<code>i = c;</code>".</p> <H3><A NAME="section-8"></A>Section 8: Boolean Expressions and Variables </H3> <H4><A NAME="question-8.3"></A>8.3</H4> <P>This is a reference to a wonderful stand-up comedy routine about metaphysics. The same routine was the origin of the oft-repeated "Yes, fish think, but not fast enough."</P> <H3><A NAME="section-9"></A>Section 9: C Preprocessor</H3> <H4><A NAME="question-9.1"></A>9.1 </H4> <P>Of course, they don't. It's just a joke about the "it worked here, it must be standard" attitude one sees from some newbies.</P> <H3><A NAME="section-10"></A>Section 10: ANSI C</H3> <H4><A NAME="question-10.1"></A>10.1</H4> <P>A lot of readers in comp.lang.c have been known to flame Herbert Schildt (who is an observing member of the committee) for his books on C, which frequently contradict the standard.</P> <H4><A NAME="question-10.8"></A>10.8</H4> <P>Of course, it was because of the specialized needs of certain committee members, but not like that.</P> <H4><A NAME="question-10.10"></A>10.10</H4> <P>Zork references.</P> <H4><A NAME="question-10.13"></A>10.13</H4> <P>Actually, it's a hack some compilers have to indicate that a file should not be re-processed, even if a series of <code>#include</code>s would indicate that it should be seen twice - but this is a good way to point out the complete impossibility of relying on portable behavior from a pragma.</P> <H3><A NAME="section-11"></A>Section 11: Stdio</H3> <H4><A NAME="question-11.2"></A>11.2</H4> <P>The line about "fast printf" was a reference to the common belief that "fgrep" (fixed grep) is "fast grep".</P> <H4><A NAME="question-11.7"></A>11.7</H4> <P>I felt that the document needed at least one moderately vulgar joke. :)</P> <H4><A NAME="question-11.9"></A>11.9</H4> <P>Pretending that the problem is the return key, not the need to wait for a signal than input is complete. </P> <H4><A NAME="question-11.15"></A>11.15</H4><P>More Zork references.</P> <H3><A NAME="section-12"></A>Section 12: Library Subroutines</H3> <H4><A NAME="question-12.9"></A>12.9</H4><P>Another text adventure, this time, Colossal Cave Adventure.</P> <H3><A NAME="section-13"></A>Section 13: Floating Point</H3> <H4><A NAME="question-13.1"></A>13.1</H4> <P>Many early Pentiums had a floating point bug.</P> <H3><A NAME="section-16"></A>Section 16: Strange Problems</H3> <H4><A NAME="question-16.1"></A>16.1 </H4> <P>A general comment on the importance of explaining what you think the problem is. </P> <H3><A NAME="section-18"></A>Section 18: System Dependencies</H3> <H4><A NAME="question-18.3"></A>18.3</H4> <P>Whiteouts are a way for a filesystem mounted "over" another filesystem to indicate that there is no file of a given name. This is pretty arcane, and totally irrelevant. </P> <H3><A NAME="section-19"></A>Section 19: Miscellaneous</H3> <H4><A NAME="question-19.1"></A>19.1</H4> <P>In other words, "yes".</P> <H4><A NAME="question-19.6"></A>19.6</H4> <P>The <code>#log%</code> is a reference to the RCS behavior of putting logs in places where it sees <code>$log$</code>. At least on my keyboards, the punctuation used is close, but not close enough. The reference to 1 Kings 7:23 is one of the places where particularly crazy people have gotten the idea that pi is exactly 3. (In fact, the numbers given are clearly only to one significant figure, and pi, to one significant figure, is 3.)</P><P>Of course, the main point is that a math header will likely be so dependant on the system as to make it irrelevant to anyone else. Same with any other header, really. </P><H4><A NAME="question-19.27"></A>19.27</H4><p>What scares me most is that people have made it as far as Section 7 or so correcting "errors". Many of the "corrections" I've gotten over the years were actually <em>less</em> accurate than the material "corrected".</p> </BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -