Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: [Solved] Need some help getting to my feet Date: Wed, 25 Apr 2018 09:24:46 -0700 Organization: None to speak of Lines: 52 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="6422cd8020e26cadac40843395f612df"; logging-data="11104"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eoS9tx4tR1gVPZTyE81oV" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:pORG821lY5gAISy3az4CK2VET1U= sha1:x1duS/ImOuimgq/CY604IF4u0bA= Xref: csiph.com comp.lang.c:129723 Malcolm McLean writes: [...] > You have to be careful with the consensus. > > For example the consensus in this ng will be that Schild's tutorials > should be avoided. That's because they contain technical errors. But > that doesn't actually matter too much for a tutorial, people who don't > have much experience teaching often think that teaching an error is > a disaster, in fact it's often better to teach a simplification. For > example void main() is an error in C (C programs must return a > success / failure flag to the environment, so it should be int main()) > but the vast majority of compilers accept it, and in fact the flag isn't > really of any use for beginner-level programs. I strongly disagree with almost everything in that paragraph. Technical errors in a tutorial do matter. Victims of bad tutorials can pick up bad habits that last for decades. Schildt's use of void main() is inexcusable, not just because it's wrong but because it's a symptom of his technical sloppiness. He wrote a book "The Annotated ANSI C Standard" consisting of the 1990 ISO C standard with his annotations on facing pages. He used "void main(void)" as an example right next to the section of the standard that requires the return type to be int. In some environments (particularly Unix-like ones), returning a success/failure indication to the calling environment is *important*. Using "void main()" or "void main(void)" rather than the correct "int main(void)" isn't even a significant simplification. And it's just one of probably hundreds of fundamental errors he made in that one book. Incidentally, the C90 standard didn't even have the "or in some other implementation-defined manner" wording; that was added in C99. So "void main(void) {}" unconditionally has undefined behavior in C90, the standard he was discussing. https://www.davros.org/c/schildt.html https://www.seebs.net/c/c_tcn4e.html Teaching a simplified version of something can be useful, but that's not what Schildt did. He just got things wrong. [...] -- 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"