K&R Learning Issue

This is a discussion on K&R Learning Issue within the C Programming forums, part of the General Programming Boards category; I'm not a C programmer and have never read any C programming book, so I really cannot say. I'd suggest ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    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.
    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. #17
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    265
    Well I learned C++ first. I've never read a book on C aside from K&R. The only reason I am familiar with the language is because there is a lot similar between C and C++. When going through others peoples code, figuring out how it works, it came pretty easily. That and there is a lot to be read on the internet. Aside from that, it takes practice and time. Start yourself some projects once you think you're ready.
    Last edited by Syscal; 09-04-2010 at 08:23 AM.

  3. #18
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    Quote Originally Posted by Elysia View Post
    Adak: Have you tried using Code::Blocks for your small projects? It's fast, snappy and the compiler GCC isn't very slow, either. If those are the reasons you still use TC, then perhaps you can find an alternative that's modern. Not saying you should, but perhaps you should try it and see if you like it.
    Visual Studio is arguably fat, bloated and slow. Unfortunately. But perhaps C::B might be suited for your small projects.
    I've recently moved to C::B / GCC and need to say, that G++ is REALLY slow (compared to old Borland's, don't know gcc). Compiling projects including 50+ modules is very time consuming on different optimization levels (maybe because of heavy precompiled header usage?).

    The CodeBlock IDE itself is pretty nice especially when it comes to project management, and is _very_ intuitive. Some of the code editor features are annoying (for example, a delay after pressing arrows to scroll sources' page tabs or opening .h/.cpp in separate tab after switching) but that's not such a problem.

    I'm sure it's way better for a beginner than MSVC with thousands of windows.

  4. #19
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    Now I am 26 and just finished my MSc (in IS Management), I am highly motivated at the moment and have a few weeks off before I start work, I am looking to get into C/C++ in the meantime and read that K&R was the C bible.. Due to its age, is it perhaps not better to learn from a newer book? Or would the process of going from K&R C -> Modern C serve me well?
    No, no and no!

    K&R is the best C book out there - made by creators of the C language.

  5. #20
    Registered User
    Join Date
    Sep 2010
    Posts
    6
    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.
    And that's why I have K&R

  6. #21
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Quote Originally Posted by Tool View Post
    No, no and no!

    K&R is the best C book out there - made by creators of the C language.
    C is now an ISO standard, not some american company's pet project.
    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.

  7. #22
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    265
    Maybe this is off-topic:

    Elysia, why does your sig ask "Why did the Java creators shoot themselves in the foot"?

  8. #23
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    C is now an ISO standard, not some american company's pet project.
    Never had problems running any code from K&R in 2010, therefore i'm preety sure it conforms to the standard.

    The reason i am suggesting K&R is because i have read the whole book, did all the exercises and i can assure you that, if you go through this book theraly, you will have absolutely NO problem switching to ANY language in a very short period of time, especially C++ because of the similar syntax.

    Examples in K&R are amazing - they do not give out just any random examples - they give you examples of code in which you can learn C itself!

    One example of this is where they teach you a bit of recursion by making a "parser" which takes input like char (*a)[20]; and then produces output - a: pointer to an array. This way you're learning recursion, general programming methods and C syntax itself - how to read complicated declarations! I did this exercise more then half a year ago - and yet i still remember how to read complicated declarations and rules for them.

    Also, in the 8th chapter you'll learn a bit of system programming and see how things work more in-depth. For example, you'll write your own printf() function, scanf() (this is ch7), your own FILE structure and functions related to it. Therefore you will know how I/O system work better then most people who learned C.

    Not to mention pointers - the core of C - authors were smart enough so they put out more then 20 exercises for the pointer chapter.

    You'll also learn how malloc and free works, therefore giving you a bit of knowledge about how dynamic allocation actually works - it's not that simple as most people think. You'll see that C and it's functions are more complex then you think.

    You'll learn alot about parsing, bit operators, how to write some of the trivial functions like itoa(), reverse(), atoi(), how to convert data (for example, string to number or number to string).

    At ch4 you'll learn what's stack by writing your own calculator.

    You'll learn all the important aspects of the language through examples presented in the book and the exercises, for which you have solutions on the internet (for free!).

    AND THIS, is exactly the reason i'd preffer K&R over any other C book - because it has free solutions for the exercises on the internet. From the solutions you will be able to improve your knowledge dramatically, cause usually examples in the book aren't enough for you to learn how to solve exercises in the book.
    Last edited by Tool; 09-04-2010 at 08:36 AM.

  9. #24
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    265
    Quote Originally Posted by Tool View Post
    char (*a)[20];
    I always fail to see the purpose of the pointer to an array. You could just say:

    Code:
    char a[20];
    The book may be short but you'd best spend some time applying what you learn.

  10. #25
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Quote Originally Posted by Syscal View Post
    Maybe this is off-topic:

    Elysia, why does your sig ask "Why did the Java creators shoot themselves in the foot"?
    Since in my opinion Java is a piece of crap language.
    It is built off C++, but they've taken everything good and thrown it out in favor of dumbing it down. How about no operator overloading? References which are clearly a hybrid of pointers and references in C++, yet not as easy as references? Those are two examples of the mistakes they made.
    Hence my mockery of why did they shoot themselves in the foot. Why did they destroy everything good about the language they tried to improve?

    Quote Originally Posted by Tool View Post
    Never had problems running any code from K&R in 2010, therefore i'm preety sure it conforms to the standard.
    I haven't read the book, but perhaps you can tell me if there are any code such as
    Code:
    main ()
    {
        /* Bla... */
        /* NOTE: No return statement. */
    }
    And
    Code:
    foo(p)
    void* p;
    {
        /* Bla... */
    }
    The reason i am suggesting K&R is because i have read the whole book, did all the exercises and i can assure you that, if you go through this book theraly, you will have absolutely NO problem switching to ANY language in a very short period of time, especially C++ because of the similar syntax.
    Also, I think that is a little much to state. How you go about C programming is totally different from Java/C++.
    Some pieces will still be missing.
    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.

  11. #26
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Expert C Programming: Deep C Secrets is an excellent adjunct to K&R for straight C.

    EDIT: Implicit main() is part of K&R, true. The old function implementation posted is not. Up-to-date C standards indeed dictate that the entry point to a C program be either
    Code:
    int main(void)
    or
    Code:
    int main(int argc, char *argv[])
    so that is a failing; however, modern C compilers will warn of this issue.
    Last edited by rags_to_riches; 09-04-2010 at 08:42 AM.

  12. #27
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    I haven't read the book, but perhaps you can tell me if there are any code such as
    I'm 100% sure i've never seen a K&R example with no return statement in main function.

  13. #28
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Also note the missing return types.
    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. #29
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    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.

  15. #30
    Registered User
    Join Date
    Jul 2009
    Location
    Croatia
    Posts
    272
    Also, I think that is a little much to state. How you go about C programming is totally different from Java/C++.
    Some pieces will still be missing.
    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.

Page 2 of 4 FirstFirst 1234 LastLast
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, 01: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, 02:55 PM
  5. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 04:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21