ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've been learning C for the last few weeks and have made some good progress; but as the "practice" programs I write start getting more complex I was thinking of buying a book with common C pitfalls, something along the lines of Prentice Hall's "Efective Java".
Of the few books I found on amazon one was released in 1994 and the other in 1989, so both are pre-C99 and the book reviews are almost as old too
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
A really good book -- one that I use as a textbook for teaching "intermediate" and "advanced" C -- is Steven Kochan and Patrick Wood Topics in C Programming (rev.ed.; New York: John Wiley & Sons, Inc., ISBN 0-471-53404-8, 1991). This book, along with a couple of others by the authors, is excellent -- see http://www.kochan-wood.com or Amazon -- and is written for Unix and Unix-like systems.
About the age -- C hasn't really changed all that much since the ANSI standard was adopted (and there's no reason that it should, if you think about it). What has changed, though, are vendor "enhancements" (which you should avoid like the plague). If you're going to get serious, you really need to pay attention to writing code to ANSI/ISO standards (avoiding all vendor-specific library routines and the like; the will come back and bite you). Kochan and Wood books are well-written, provide working examples for every subject, and, for my money, you can't go wrong.
About learning standard ANSI/ISO C, I think I am already on the right track there. I'm following Stephen Prata's "C Primer Plus" (5th ed.), which according to the author, strictly follows the standard C library.
...but as the "practice" programs I write start getting more complex I was thinking of buying a book with common C pitfalls, something along the lines of Prentice Hall's "Efective Java".
One of the best books on C (next to The C Programming Language...) is surprisingly called C Traps & Pitfalls by Andrew Koenig:
Most C programming books will do, unregarded their age. I suggest Googling for C/C++ topics, because proper coding, pitfalls, coding style etc are favoured topics among C/C++ programmers and a lot of good essays are spread out on the net. Universities have a lot of this stuff. Philip Machanick had a good tutorial on C/C++ called "C and C++ in 5 days" for those in a rush. Should be available somewhere on the net.
i was just wondering if this would be a good place to tell everyone my opinions on C - i hate it, mostly, but maybe i'll start a new topic. to the OP - can i ask WHY you're learning C?
I'm doing Computer Science, so at some stage I will have to work with it.
But thats not my only reason; C is a very powerful language, and although that also means that application development might be a bit harder than say Java, there is almost no limit to what you can accomplish using C.
I really enjoyed working with MIPS assembly last semester and since C gives the same power and speed as assembly does but in a higher level form, I feel like I would benefit from learning it.
Besides, I think its fun.
I'm doing Computer Science, so at some stage I will have to work with it.
But thats not my only reason; C is a very powerful language, and although that also means that application development might be a bit harder than say Java, there is almost no limit to what you can accomplish using C.
I really enjoyed working with MIPS assembly last semester and since C gives the same power and speed as assembly does but in a higher level form, I feel like I would benefit from learning it.
Besides, I think its fun.
Ahh yes, if you're doing computer science, it's probably good and *exactly* for the reason you say - but do you realise where it came from? If you're already a little familiar with it, post your guesses, I really want to chat about this with someone.
Do you realise that you're not supposed to be able to malloc in a HLL? Defining an array subscript is enough.
And why, WHY, do you have to define everything (vars and funcs) before you can use them? WHY? Why is the compiler so dumb?
And why, WHY, do you have to define everything (vars and funcs) before you can use them? WHY? Why is the compiler so dumb?
Umm...declaring variables is the SANE way to do things. It makes it easier to keep track of variables and to debug the program.
Creating variables as you go along might be ok in a small scale project (say a simple bash script), but its a sure way to create unnecessary headaches in a larger project.
And about "defining" functions...what do you mean? You have to create the damn things before you can use it
Maybe you are talking about function prototyping, in which case I dont see any problem with that either.
Quote:
but do you realise where it came from?
Where C came from? AT&T Bell Labs...but why does that matter?
And why, WHY, do you have to define everything (vars and funcs) before you can use them? WHY? Why is the compiler so dumb?
Because by doing this you eliminate a whole class of errors, that otherwise can send you on extended, twisted, and infuriating bug hunts when your HOL implicit typing leads to the wrong type! By doing this, you tell the compiler that: "yes, this really IS the way I want it" rather than letting the compiler assume.
C is my favorite language, and I speak several assemblers, C, C++, C#, numerous dialects of Fortran, several dialects of Basic, perl, PHP, some Java, a bit of Python, and some other languages you've never heard of.
Umm...declaring variables is the SANE way to do things. It makes it easier to keep track of variables and to debug the program.
Creating variables as you go along might be ok in a small scale project (say a simple bash script), but its a sure way to create unnecessary headaches in a larger project.
And about "defining" functions...what do you mean? You have to create the damn things before you can use it
Maybe you are talking about function prototyping, in which case I dont see any problem with that either.
I mean before you can do int jump { jump ; }or whatever, you have to say "int jump();" just by itself - THAT thing.
Where C came from? AT&T Bell Labs...but why does that matter?
No - why was it created? In the 70s or whenever they were making it, high level languages were just about starting to be designed and made - if you've programmed in assembly, of course you'll realise that a pointer is a [] is asm (indirection), AND C has malloc - so, like a good comp sci student, care to take a guess what the purpose behind inventing it was?
Last edited by resetreset; 07-21-2008 at 03:16 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.