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

C/++/# Learning C by myself

  1. Dec 26, 2015 #1
    Hi all, im looking to learn C by myself since it is a programming language that is used in my micro controllers class that i am going to take during the upcoming Spring semester at my university. I was wondering how i should go about doing this? I was thinking of using book The C Programming Language by Brian Kernighan and Dennis Ritchie. Would this be a good idea for a person that has only taken 1 cs class that was taught in C++ (intro cs class covered stuff like datatypes, variables, functions, arrays, flow of control, and loop.) Do you have any other suggestions of materials, such as online lecture courses, different textbooks or youtube videos, that i should use instead?

    kind regards,
  2. jcsd
  3. Dec 26, 2015 #2


    User Avatar
    Gold Member

    That's the book I used to learn C. Worked well for me, but I was an experienced programmer when I started it.
  4. Dec 26, 2015 #3
    I think i may just use this book. I was skimming through the tutorial chapter, and it was written nice and concisely, with a few examples and exercises, just like textbooks should be written. It doesnt to give you 20 page introductions, which many textbooks do.

    do you think the text and the exercises are good enough to learn the language or is there anything else that i should be doing?
  5. Dec 26, 2015 #4


    User Avatar
    Gold Member

    I think you should go through that book, THEN worry about what to do next. It really has all you need. It IS concise so you need to be careful that you don't go too fast or skip stuff.

    I would also start WRITING simple (VERY simple) programs and add to them as you learn new things. I created a program called C PLAY that basically, by the time I was done, contained a usage of every construct in the book.
  6. Dec 26, 2015 #5


    Staff: Mentor

    I agree with phinds that the K & R book is a good choice, especially since you have already had a class that was presented in C++. If you were coming in to C as a complete novice, I might not suggest the K & R book.
  7. Dec 26, 2015 #6

    jim mcnamara

    User Avatar

    Staff: Mentor

    Phinds said 'do not skip stuff'. He was very right. C has this nasty thing- it will let you write code that will do odd things, like crash unexpectedly. This nastiness is called 'undefined behavior'. It is hard to create in most upper level programming languages, awfully easy to do in C. Follow the book scrupulously. Code the way you learned from the book and life will be good.
  8. Dec 26, 2015 #7


    Staff: Mentor

    I concur k&r is an excellent book to learn from. Its easy to read and very concise.
  9. Dec 27, 2015 #8


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    Kernighan and Ritchie is the book by the people who originally defined C, so it is a good book. As a beginner, you may want more explanation in some places, but the internet can fill in where needed. In general, I think it is a good book for a beginner and will still be your main reference when you are an expert.
  10. Dec 27, 2015 #9
    What I also like is that the exercises are useful. You'll have to try and think about how certain functions you'll use very often actually work.
    I haven't done most of them but when I read them I liked them more than the assignments we were given for the class that used the book.
  11. Dec 28, 2015 #10


    User Avatar
    Science Advisor
    Gold Member

    K&R is definitely a good book but if you want some things explained, I'd suggest Deitel's book "C How to Program". I studied through this book and some others as well when I was learning C and I found that it is particularly good at explanations of concepts, has many exercises and projects - particularly now with the LiveCode approach, helps to develop good programming habits in general and - with no intention by my side to advertise it, it is definitely an excellent book.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook