References for learning C

Hello,

I have a reasonably knowledge regarding java and I would like to learn the C language, it’s just curiosity and I want to have a better understanding of the lower level languages (comparing to java). So any links to tutorials, advices and things I should know would really be helpful. Links to C++ tutorials would be good too but I’m more focused in learning C first.

PS.: I already know java’s syntax is based on C and I have written a few solutions for codechef using C and C++. I also searched the net and found some tutorials therefore I wrote this to get a little personal guidance from people that already work with those languages. I have programmed in java for a while so I can safely say that I already know the very basis of programming.

Two best links for c ->

Two best links for c++ ->

Enjoy :slight_smile:

6 Likes

Hi @junior94, I know that you are pretty familiar with Java, I’ve been watching you since I have joined Codechef and you were an active member in discussions and contests.

Well, still since you will only be needing the precise materials in these languages C and C++, I would recommend to pick them one by one.

Now regarding tutorials and books, in C I thought I know very much of C to use in daily practice until I came to read this book, The C Programming Language by Dennis Ritchie, it is not very expensive and a very useful manual for C; I must say it is not for beginners, so you will like it.

For C++, I still consider the best reference is by the creator himself, The C++ Programming Language.

You can go through the C book in few days, but it is the C++ where I would like you to spend more time, few months. Here is a healthy lot of information regarding good and bad C++ books, you can refer to it. As there are many similarities in C++ and Java, it will be really easier for you to go pick C++ once, but it is a good language once we go in deeper.

Online tutorials, there are plenty and there is no need to mention all or few of them here.

Although for you, a very basic grasp in the language would include:

  1. Using basic translation of programs that you write in Java to C++
  2. Using containers and iterators wisely. Like this problem can be solved with use of sets pretty wisely and in a much compact manner than when you go to actually write algorithm for it. I can provide you that solution if you wish.
  3. Using the STL algorithm functions e.g. sort(), next_permutation(), reverse(), sort() with a comparator (to name a few), to fetch you results faster than what you would have got after writing the entire code for the same.

Lastly, you know pretty well that the more you practice the more you’ll get casual with the language. So wish you good luck and welcome to the C++ club, where majority of programmers write in any competition.

I am keeping this answer an open edit-able answer so that more experienced programmers can add more points that I might have missed or that I am yet to learn :wink:

2 Likes

@bit_cracker: Thanks, I already knew the last link but not the other ones. I had a quick view and all of them seem pretty useful so thanks a lot.

@bugkiller: I have been watching you too and some of the other fellow coders as well. I know that C++ has more features than C (The reason for the ++ of course) and I know that I will definitely use way more C++ than C in the future but now I’m more interested in learning C because I want to get closer to assembly language.

I am very aware that high level languages were written to make it simpler and more efficient to read and write code but low level code really fascinates me and I’m sure understanding it will help me to understand better what the code really does and maybe someday I might use it to create something new.

You might be asking why don’t I just learn assembly directly, well I tried: I’ve watched a lot of videos, read a lot of stuff about memory, registers and so on… I even wrote a Chip8 interpreter with the help of tutorials. I learned a lot from those things but I couldn’t evolve much in assembly language because most of the assembly tutorials use calls to external libraries and that isn’t very appealing for me. So now I decided to start up and go deeper step by step so that one day I can write assembly code based on instruction manuals without much need for tutorials. As for the high level languages, they’re still my main focus and I want to become a great Java programmer (I know there’s a long road to go) and maybe a C++ one too (C and C++ fascinate me a lot as well and I will do my best to keep up with those languages)… Anyway thanks @bit_cracker, @bugkiller and everyone else that answers this question.

Actually I ran into a problem yesterday in a topcoder single round match that I could have easily solved using the next_permutation() method but I was trying to solve it in java and I didn’t have much time to finish it… I still have a little problem managing my time and coming up with quick solutions in short contests

@junior94 >> same here brother for the short contests part. I need a lot of practice. Had a challenging time in GCJ this year due to lack of practice although the problems were damn easy. Well, all the best to you too for the cook-off and the future contests.

1 Like

I will get back to you on this topic after few days, after my semester exams. I have something similar in my mind.
I learned a bit(not a byte :D) of assembly language in my 8085/8086 Microprocessors course, after that I couldn’t continue it.

@junior94 >> As promised, I’m here to add some info related to the assembly language part.

You can install SPIM simulator to learn the basics, I did and it provided me a healthy lot of information. I used it to add some machine descriptions in gcc.

You can try to visualize the Assembly translation of few basic C programs using gcc, if you want to know the steps I can tell you how to view the in-translation-phase-code of the original code that we write; after the compiler does the optimizations and all, and finally the assembly code. It helped me understand the mechanism even better.

Observation is the best technique to understand assembly and the inner mechanisms, thats what I learned.

1 Like

Wow thanks… I’ll try it out… I prefer using NASM syntax but I’ll definitely check it out this weekend… Thanks @bugkiller, sorry for the late reply, I haven’t checked this post for a while…

@junior94 >> No problem. Wish you good luck! :slight_smile:

1 Like