Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How best to learn C

  1. Feb 6, 2010 #1

    AK2

    User Avatar

    I'm presently an engineering undergraduate student. Learning C language is very important for my degree program. I'm using Sam's Teach Yourself C in 21 days. Its obvious I can't learn C in 21 days. I have covered 10 chapters out of the 21 chapter book. Its kind of frustrating learning C that I had to slow down my pace and look through the first 10 chapters. So what is the best way to learn C programming. I read some where that C is a programmer's programmer language. C is the first computer program I am learning. Any advice will be welcome
     
  2. jcsd
  3. Feb 6, 2010 #2

    jtbell

    User Avatar

    Staff: Mentor

    The same way a violinist gets to Carnegie Hall: "Practice, practice, practice!"
     
  4. Feb 6, 2010 #3
    Throw the book out through the window and start to code.
     
  5. Feb 6, 2010 #4

    AK2

    User Avatar

    I have been practicing but I'm losing interest. Are there any sites where I can get problems to practice on since I've done all the problems in the chapters I have covered so far.

    How will that help me?
     
  6. Feb 6, 2010 #5
    You can't learn swimming from books. You actually have to get in the water at some point.
    The same is with coding. You actually need to write code to learn it well.
    Sit at your computer. Your C compiler should have a reference, use that for help and write code. Again and again.

    The only "difficult" thing in C with which I seen ppl (who never programmed in any language before) having issues with are the pointer mechanism, & and * operators, and array addressing. Type conversions should be easy. Rest of C is self-explanatory.

    If you are bored with problems, start to write small programs. Find something which excite your imagination and make a program :P
     
  7. Feb 6, 2010 #6

    AK2

    User Avatar

    Thanks. I will take into practice what you just posted.
     
  8. Feb 6, 2010 #7
    The best book I know is the first one: "The C programing Language", by Kernighan & Ritchie (the fathers of the C language).
    No several equivalents examples, not twice the same thing. It is a concise book, and each line is valuable.
     
  9. Feb 7, 2010 #8

    AK2

    User Avatar

    Does it have a lot of practice problems and examples. I need something like that to master C at a faster pace.
     
  10. Feb 7, 2010 #9
    Yes it does have practice problems and examples throughout the book. I highly recommend it.
     
  11. Feb 7, 2010 #10
    Yes. The authors work through the examples and put a bunch of practice problems at the end of every chapter. It's also really clear and concise (a model of good technical writing), which makes it much easier to get through.
     
  12. Feb 8, 2010 #11

    AK2

    User Avatar

    Thanks. I'm ordering the book now.
     
  13. Feb 11, 2010 #12
    http://projecteuler.net/

    This is a good site irrespective of what language you are studying. It starts up with quite simple problems but eventually they become quite difficult.
     
  14. Feb 12, 2010 #13
    The approach of just keeping with the sample C programs is an admirable one. However if you really are having trouble focusing on the C examples you may want to consider learning a "simpler" language, like Python or Java, and then coming back to C when you have a better grasp of programming fundamentals.

    There are kind of two things you really need to learn, one is "how to program", the other is how to program in C. It is perfectly possible to learn both at once. But for some people trying to start out with C, with its added requirements (compared to some languages) of understanding how memory addresses and allocation work just to do basic things with strings, obscures what you really need to learn about programming. It's also the case that doing certain "real things" (like, I don't know, editing a PNG) become possible lower on the learning curve with some of those other languages, which may make it easier to maintain that focus.
     
  15. Feb 13, 2010 #14

    harborsparrow

    User Avatar
    Gold Member

    write some programs that you can use: a hex dumper, a program that reads a text file and numbers the lines, a syntax colorer, etc
     
  16. Feb 13, 2010 #15
  17. Feb 14, 2010 #16
    I found C very easy after I learned assembly language.
     
  18. Feb 14, 2010 #17

    harborsparrow

    User Avatar
    Gold Member

    @rootX: I've heard a lot of people comment that C *is* pretty much the same as assembly language. It does not permit you not to know everything about what is happening within the memory.
     
  19. Feb 17, 2010 #18

    AK2

    User Avatar

    K & R The Computer Language book is advanced for me. The good thing is that it has a lot of problems. I will probably start with it after I've finished the one I am using now which is a book for novices. I'm on the chapter on structures and I'm finding it to be a very interesting topics. Thanks for the responses.
     
  20. Feb 17, 2010 #19
    for all language c is base so that c should study perfectly by getting book of local author so that you can understand easily also make use of w3school website that too helps lot and lot
     
  21. Feb 20, 2010 #20
    A great book is Herb Shildt's "C++: The Complete Reference"

    C is not a great language to start with. You would have definitely benefitted from learning Basic or something first. However, you will get through it. Practice writing little console apps to do things like Conway's Game of Life, etc. Start small and work your way up. Good luck.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook