Learn C Programming Language: Tips & Resources

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
9 replies · 3K views
sanhuy
Messages
40
Reaction score
2
Hi all, I am 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,
sanhuy
 
  • Like
Likes   Reactions: Dr. Courtney
on Phys.org
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 doesn't 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?
 
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.
 
  • Like
Likes   Reactions: jedishrfu and jim mcnamara
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 into C as a complete novice, I might not suggest the K & R book.
 
  • Like
Likes   Reactions: jedishrfu
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.
 
  • Like
Likes   Reactions: jedishrfu
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.
 
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.
 
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.