I'd like to learn C but I wanted to ask if anyone knows of a good book to start with. I came across some folks who said the best one is 'The C programming language, second edition' but some reviews said that it's not for beginners. I am learning Java and UNIX on my Mac and am familiar with programming, but I still consider myself a novice (I'm learning for fun and the intellectual exercise).
So if this book isn't the right one, what else can you recommend?
And while I'm here, I thought that OS X came with a c compiler. Is that correct? I tried to search the man pages for the proper command, but couldn't find anything. If not, does anyone know where I can get one that I could run from the command line in Terminal?
If this is not the proper forum for this post, I apologize. I wasn't sure where it ought to go, and whoever's the moderator, feel free to move it if necessary.
The K&R book should be fine if you're a beginner. That book, plus Rochkind's advanced UNIX programming kept me going from my first C class through 10 years of professional C programming (albeit a long long time ago).
Joined: Jul 25, 2009
Thanks, Shawn. One more thing -- do you know if OS X comes with a c compiler? I'm on snow leopard right now. I thought there was some command that would compile c code, (maybe I was on Leopard when I found it). Can you tell me how I would be able to? I think I read something about installing it from Xcode from one of the install DVD's, but not sure.
Almost forgot -- Advanced UINX programming -- would that be a good book to take up after 'Learning the Bash Shell?' I'm reading that right now. But it isn't the final word. So I was wondering if you knew of a book that could be the next step.
Joined: Feb 22, 2011
The Advanced UNIX programming book is actually a book about system calls on UNIX and UNIX like systems. It doesn't teach you about the shell, but how, inside of C or C++ to do the low level calls into the operating system.
As far as a good book on Shell programming, I don't know what's current. I learned with the Kernighan and Pike book, "The UNIX Programming Environment", but that was over 20 years ago. I have quite a few books on the subject, but I mostly use them for reference at this point.
OS X doesn't come with a native compiler installed. You can install XCode (http://developer.apple.com/xcode/) and use it to install make and the gnu development tools.
If you're looking for a thicker read that is a good starter for C++, Stroustrup's new book "Programming Principals and Practice Using C++" is a tomb, but covers a lot of ground from the basics through advanced topics. Once you know the basics, Scott Meyers Effect C++ series and Herb Sutters Exceptional C++ series are some of the best I've read on the topic.