Thread: Kernighan & Ritchie's vengance

  1. #1
    Newbie "%s", username's Avatar
    Join Date
    Jul 2004
    Posts
    4

    Kernighan & Ritchie's vengance

    I'm reading "The C Programming Language - Second Edition" and I'm really aggrivated at how I can't really do most of the examples with any of the compilers I've found so far. Actually, I haven't got most of them to work right (some lame instructions), but many of the Windows XP (the system I use) compatible ones (as in non-linux). don't work well with some of the examples. I don't know if I should get a different book or compiler or just give up or what, but at any rate, I won't be interested in C++ for a while. Here's a short list of some I tried.

    Dev C++ (two versions)
    Cygwin
    ICC
    Miracle C

    I don't have any money to pay, and I don't want to give away any addresses or anything. What do you all think I should do?

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    The C Programming Language, Second Edition
    by Brian W. Kernighan and Dennis M. Ritchie.
    Prentice Hall, Inc., 1988.
    Yes get a new book. Much has changed in the last 16 years

  3. #3
    ~viaxd() viaxd's Avatar
    Join Date
    Aug 2003
    Posts
    246
    What do you all think I should do?
    describe your problem better. what exactly are you having trouble with?

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    3

    Dev c++ works

    Hey,

    I used dev c++ in windows for the book and i had no problems with the compiler.

    But in order to do some of the examples, a dual booting machine will probably be your best bet.

    laterz.


  5. #5
    Newbie "%s", username's Avatar
    Join Date
    Jul 2004
    Posts
    4

    Kernighan & Ritchie's vengance

    I didn't expect a reply so fast, thanks a lot!

    First of all, I have no clue what a dual booting machine is. Unless it's something that makes your computer use two operating systems, which no one else in the family would like at all.

    I guess I'm a little bummed that some of the examples out of the book don't work with the compilers I tried. It would be really nice is the output window wouldn't close a split second after the commands are done, and I'd really like to try some of the examples in chapter one about figuring out the number of characters in input and all that. I guessed it was written for a unix machine, and I always got a bunch of error messages.

    I guess I would tinker around with it, but I've had many bad experiences with too much tinkering and I'd rather just ask.

    And like I said, I don't have any money and I'm not willing to give away much personal information.

  6. #6
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    As for the closing immediately, here.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  7. #7
    Newbie "%s", username's Avatar
    Join Date
    Jul 2004
    Posts
    4

    Kernighan & Ritchie's vengance

    Sorry I couldn't find that one in the FAQ. I just might work a little less efficient when tired. Maybe I'll check out the FAQ more, but I'm still a little curious about what might be a better book for me.

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If you use the code from that FAQ article, it should stop the window from closing instantly.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could always add this to the bottom of main, right before the return:
    Code:
    for(;;);


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by quzah
    You could always add this to the bottom of main, right before the return: for( ; ; );
    I would recomend adding a simple getch(); at the bottom... a key is pressed and the program finishes... that for(; causes a infinite loop, and to close the console window you have to create an error...

  11. #11
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    And yet another of quzah's jokes goes over someone's head

  12. #12
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Yes get a new book. Much has changed in the last 16 years
    But K&R-II is the most up to date K&R available.
    If it's got the big red "ANSI-C" stamp on it, it's good.

    Perhaps the OP should explain the problem - like maybe they're stuck with generating EOF for some of the early examples in the book.

    > Miracle C
    Please remove it from your system and never mention it again.
    It is not a C compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt about kernighan and ritchie excercise 1-12
    By afol_1 in forum C Programming
    Replies: 12
    Last Post: 01-05-2009, 07:31 PM
  2. Examples from Kernighan book
    By kyaneos in forum C Programming
    Replies: 5
    Last Post: 09-09-2007, 10:24 AM