Thread: K&R Learning Issue

  1. #31
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    ANSI is irrelevant. If it does not adhere to ISO C, it's no good.
    Like I said: C is now an ISO standard, not some american company's pet project.
    Now, that doesn't mean it's bad if the code contained within is compatible with the ISO standard, but don't tout the ANSI standard. It's dead and rightly so.

    Quote Originally Posted by Tool View Post
    Ofcourse - what i'm saying is that pieces will be missing, MANY pieces, but you will have absolutely no problem in learning and easily comprehending those pieces.
    No, I still think that is too much to state.
    Java/C++ is TOTALLY different from C programming. Concepts you knew in C will most likely all be thrown out the window. It's a completely different environment.
    So it isn't easy. It is possible and it is much easier than if you have no experience, certainly.
    Last edited by Elysia; 09-04-2010 at 08:50 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #32
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    266
    Quote Originally Posted by Tool View Post
    You might be reffering to K&R first edition - there might be such deprecated examples there, but i've never seen such a thing in K&R 2nd edition.

    Possibly, i've seen main() without int in front of it, but i'm not sure about this, i'll check it.

    K&R does conforms to ANSI ISO - look at the cover page infront.
    I can confirm there is a second edition that does have a return type and returns. The first edition didn't

  3. #33
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I have the Second Edition, and on page 6, we have this.

    I cannot find a main definition in there that is explicitly typed as main, although later there are returns from the main function.

  4. #34
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    This is bad since that example neither conforms to C90 nor C99.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #35
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    Didn't my original post suggest this, as I said I put the additional int main() and return 0 myself before compiling, but posted the exact code snippet here; I put the return stuff in after receiving the warings - it is good to know why I got those warnings though - cheers!

  6. #36
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    The fact that you paid attention to your warnings and fixed them puts you well on your way to being, at the very least, an above average programmer

  7. #37
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    Quote Originally Posted by rags_to_riches View Post
    I have the Second Edition, and on page 6, we have this.

    I cannot find a main definition in there that is explicitly typed as main, although later there are returns from the main function.
    Oh my god.

    This is probably the only example in the book without the return statement, and i agree with authors taking it out - it's done because they didn't want to confuse beginners with irrelevant details.

    You're just plain dumb if you judge the book over one example at the beginning of the book. Cause every serious example i tried on my machine from K&R worked perfectly.

    @Elysia
    It is ISO.
    Last edited by Tool; 09-04-2010 at 10:51 AM.

  8. #38
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Tool View Post
    Oh my god.

    This is probably the only example in the book without the return statement, and i agree with authors taking it out - it's done because they didn't want to confuse beginners with irrelevant details.
    What is done because they don't want to confuse?

    @Elysia
    It is ISO.
    What is ISO?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #39
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I was simply pointing out that there ARE examples in K&R where they do not return 0 from main. Reading further, I note they start returning a value from main after the introductions to functions in section 1.7, in which it is stated:
    In the interests of simplicity, we have omitted return statements from our main functions up to this point, but we will include them hereafter, as a reminder that programs should return status to their environment.
    So Tool, you are correct. It is part of the introduction process for beginners.

    Oh, and in the process of reading further, I also see that shortly after the above quote they show the old function implementation mentioned above, only as a bit of history.

    All of that is on page 26 of the Second Edition of K&R.
    Last edited by rags_to_riches; 09-04-2010 at 11:09 AM.

  10. #40
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    Thanks you, rags_to_riches.

  11. #41
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Quote Originally Posted by Elysia View Post
    Any book that tries to learn implicit main, fail to return 0 at the end and assumes linux is a book that needs to be dumped and burned.
    C is a platform independent language. Therefore, a book should not assume any particular platform.
    It is also important to know safe and modern C programming instead of outdated syntax and idoms. Therefore, I recommend that you dump that book.
    Wow. There is nothing in K&R2 that assumes Linux. As for the implicit main, and the return statement, someone else has pointed out that they did not introduce those concepts immediately. Do you really advocate books should be burned?

    Quote Originally Posted by Elysia View Post
    I'm not a C programmer and have never read any C programming book, so I really cannot say.
    I'd suggest the C books topic.
    Now it is starting to make sense. Elysia, you have not even read K&R2, and you are totally dumping on it. Would you rather the OP learn some "safe" non-standard Microsoft extensions to the language? Seriously. If you were not so bigoted toward the language which is the father of your beloved C++, you might be able to learn something.

    @ the OP - pay no attention to Elysia on this matter. K&R2 is a great book to learn about C programming. If you master what is there, you will have no problem coming up to speed on the C99 standard, and you will be a pretty handy C programmer to boot!

  12. #42
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No. Never advocated anything about K&R2, only the first edition.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #43
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by kermit View Post
    Wow. There is nothing in K&R2 that assumes Linux. As for the implicit main, and the return statement, someone else has pointed out that they did not introduce those concepts immediately. Do you really advocate books should be burned?
    No. Never advocated anything about K&R2, only the first edition.

    Now it is starting to make sense. Elysia, you have not even read K&R2, and you are totally dumping on it. Would you rather the OP learn some "safe" non-standard Microsoft extensions to the language?
    Yes, because the C committee is so stubborn that they refuse to add functions that would lessen the danger of buffer overruns.

    Seriously. If you were not so bigoted toward the language which is the father of your beloved C++, you might be able to learn something.
    Perhaps I wouldn't be if it wasn't so seriously lacking in everything.
    Take a look at C1X. Then compare to C++0x. What do you see? I see a paltry list of features coming. The only good thing is gets_s and multi-threading.
    Seriously. What the hell are they thinking? Languages are constantly evolving, yet they add nothing to C. It's already so lacking in features and library functions.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #44
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    If you want features, you should use perl. :P

  15. #45
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Or C++, which is the modern C.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. On learning and games
    By Mario F. in forum General Discussions
    Replies: 24
    Last Post: 10-14-2009, 09:01 PM
  2. Some weird issue.
    By dbzx in forum C Programming
    Replies: 7
    Last Post: 04-12-2009, 04:10 PM
  3. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-30-2009, 02:34 PM
  4. Is learning C/C++ worth it?
    By C/C++ Learner in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 11-05-2008, 03:55 PM
  5. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 04:56 AM