LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-16-2008, 06:31 PM   #1
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Rep: Reputation: 62
C pitfalls book recommendation


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

Any pointers would be appreciated
 
Old 07-17-2008, 06:20 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,037

Rep: Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756
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.

Hope this helps some.
 
Old 07-17-2008, 07:41 AM   #3
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Original Poster
Rep: Reputation: 62
Thanks tronayne, I will take a look at that book.

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.
 
Old 07-17-2008, 09:31 PM   #4
ocicat
Member
 
Registered: May 2007
Posts: 207

Rep: Reputation: 46
Quote:
Originally Posted by easuter View Post
...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:

http://www.amazon.com/C-Traps-Pitfal...6348112&sr=8-1

Koenig is one of the AT&T elite from the same generation as Ritchie, Thompson, et. al.
 
Old 07-18-2008, 06:26 AM   #5
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Original Poster
Rep: Reputation: 62
I think I will get both books.
"Topics in C Programming" seems to be the next book I would need anyway after finishing with the one I'm busy with.

Some other books from Kochan & Wood also seem to be well worth reading too.

Thanks everyone!
 
Old 07-18-2008, 08:20 AM   #6
FranDango
Member
 
Registered: Jun 2008
Posts: 101

Rep: Reputation: 15
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.

Linux Archive

Last edited by FranDango; 09-20-2008 at 05:35 AM.
 
Old 07-19-2008, 07:00 AM   #7
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Rep: Reputation: 51
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?
 
Old 07-19-2008, 11:19 AM   #8
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Original Poster
Rep: Reputation: 62
Quote:
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.
 
Old 07-20-2008, 05:14 AM   #9
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Rep: Reputation: 51
Quote:
Originally Posted by easuter View Post
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?
 
Old 07-20-2008, 06:03 AM   #10
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Original Poster
Rep: Reputation: 62
Quote:
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?
 
Old 07-20-2008, 12:37 PM   #11
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
Quote:
Originally Posted by resetreset View Post
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.
 
Old 07-21-2008, 03:14 AM   #12
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Rep: Reputation: 51
Quote:
Originally Posted by easuter View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a book recommendation p3nguin Red Hat 1 07-06-2006 02:45 PM
Book recommendation? cmackay Linux - Newbie 3 01-07-2004 11:25 PM
Book Recommendation jasonmantey Linux - General 9 12-14-2003 01:06 PM
Book Recommendation jasonmantey Linux - Newbie 4 12-14-2003 07:19 AM
book recommendation? mark_2811 Linux - Newbie 3 09-24-2003 05:39 PM


All times are GMT -5. The time now is 05:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration