Good books for learning C language.

rohan-04

New Member
Disciple
Apr 29, 2009
89
0
0
I wanted to start learning C language and i wanted to know about some good book i could use to get started. Also i am new to programming so do you think i should learn another language and get to C later or start with C? If so could you suggest some good books for the other language.
 

seshu

*
Adept
Jan 18, 2006
585
83
117
teluguthesis.com
a little bit of your background helps us to suggest the 'good books' .

Anyway , start with "Let us C" , "Working with C" , "Exploring C" etc

by Yashavant Kanetkar (BPB publications) .

C --> C++ --> Java / dot Net .... is a good sequence to develop :)
 

haraakiri

Active Member
Adept
May 28, 2009
814
24
31
39
I would strongly suggest you to start with some other programming language. C is a low level language not well suited for beginners. Something like python should be an ideal language for beginners. Or you could start with java. That's a simpler programming language.

If you anyway plan to start with C, please remember don't go with ordinary books like "Let us C" or "Programming in ANSI C" by Balagurusuwamy. These are pretty bad and you will pickup lot's of bad practices.

For beginners, IMO "A Book On C" by Kelly Pohl is decent. Follow it up with the highly acclaimed "The C programming language" by Kernighan and Ritchie(creator of c). If you find "A Book On C" difficult, you could opt for "Beginning C" by Ivor Horton, this book is extremely simple but not as good as "A Book On C".
 

rdst_1

Well-Known Member
Veteran
May 10, 2009
2,508
1,111
253
31
i've read both Let Us C and C:The Complete Reference.

here are my inferences.

the writing style and language of Let Us C is appealing,easy and good for beginners.

However having said that, i personally feel that one shouldn't go with it as misses out a lot.

Also once you've done C from Let Us C you wouldn't want to go through the same muck again and will miss out on many important concepts.

So my take is you should go for books that go deep into the subject as you are gonna read that subject once only.
 

shantanugoel

Active Member
Adept
Dec 31, 2008
304
8
32
tech.shantanugoel.com
I agree with harakiri on "A book on C" and "The C Programming Language" (K&R). They are both amazing.. although the K&R one might not have everything in line with the C99 standard..and as rdst says, start with these only because if you start with something like let us c etc, you will miss a lot of important concepts and you would not want to go through all these again when you read a better book..
 

haraakiri

Active Member
Adept
May 28, 2009
814
24
31
39
With balaguruswamy' book your basics aren't clear, they are pretty much wrong. Please guys read K&R and then decide whether what Balaguruswamy's book contains is worth reading. If you do that, and still consider Kantekar or Balaguruswamy's books as good, though I wont agree with your opinion, that's your opinion.

And please there's nothing advanced in K&R's book, it's just plain C. Might be difficult fot the beginner, but that doesn't make it advanced.

Please read his preface to understand what the book is about. It's about idioms in C. It has got particular philosophy. You need to get these right. Learning any programming language is about learning it's idioms. Nobody can teach idioms better than the creator.

I hate books containing pretty ordinary, next to useless code. K&R has got pretty good examples, correct explaination of important constructs, most C idioms and right style.

If you need to get updated on C99, you could consider "C in a nutshell". That's a very good reference.

And for Herbert Schildt fans have a look at this review. You could get great reviews of some of the best books in c/c++ from this site.

http://accu.org/index.php?module=bookreviews&func=search&rid=214

Go here and search for Schildt(select author)

http://accu.org/index.php?module=bookreviews&func=search
 

adi_vastava

Code Game Code F**K
Adept
Feb 23, 2010
884
25
42
haraakiri said:
I would strongly suggest you to start with some other programming language. C is a low level language not well suited for beginners. Something like python should be an ideal language for beginners. Or you could start with java. That's a simpler programming language.

If you anyway plan to start with C, please remember don't go with ordinary books like "Let us C" or "Programming in ANSI C" by Balagurusuwamy. These are pretty bad and you will pickup lot's of bad practices.

For beginners, IMO "A Book On C" by Kelly Pohl is decent. Follow it up with the highly acclaimed "The C programming language" by Kernighan and Ritchie(creator of c). If you find "A Book On C" difficult, you could opt for "Beginning C" by Ivor Horton, this book is extremely simple but not as good as "A Book On C".
OP has not mentioned his objective, he want to learn it for fun, for academics or what.

>>C is a low level language not well suited for beginners.

I have a different take, I agree C is a bit difficult than others but its better to learn it in start as after it all other languages will be vanilla (with certain exceptions). Python and company makes job a lot easier for you which when you work in C is not same.

So picking that after C is very easy where as same is not true for reverse.

>>If you anyway plan to start with C, please remember don't go with ordinary books like "Let us C" or "Programming in ANSI C" by Balagurusuwamy. These are pretty bad and you will pickup lot's of bad practices.

They are not good, I agree as they mere explain the syntactical stuff and do not go in implementation details but "Pick up bad practice" :S, what, can you elaborate?

The c programming language is good but very short and not at all explanatory. If you are a beginner and a self learner than "Let us C" does suits you, though its not a gr8 book for facts and details; it does a good job in giving you a start though.

Additionally "A Book On C" may become an overkill for him because of the range it cover. He is a starter if first step is this complex he may step back. Its definitely a must read but not the first one.(How can you think to learn C with one book :p)

I hope it helps.
 

haraakiri

Active Member
Adept
May 28, 2009
814
24
31
39
You say though c is difficult, still better to learn that first for whatever reasons. Again you say "A book on C" is an overkill an he may take a step back because of that.

Don't you find that contradictory?

And what range of topics does "A book on C" cover? Just normal C except the last two chapters which introduce you to c++ and java. Let us C covers windows programming at the end of it. Did you read these two books?

I would give an example of bad practices you would pickup from a wrong book. Read the following thread.

http://www.techenclave.com/programming/need-help-in-java-164065.html

Could I ask you a few questions you could answer from "Let us c"

What's the size of an integer?

What are the different argument passing mechanisms in c?

Is array a pointer? Can arrays be passed? If yes, by value or reference?

What do you keep in .h file and what in .c file?

Is the following code considered cryptic?

while(*t++ = *s++)

;

assume s,t are char * What's the equivalent?

For experienced programmers, who have missed the chance of reading "Let us c", I will suggest they do read it for fun. There are lot's of jokes. Better than most hindi movies we are made to watch. The best I remember is, one of the advantages of using structures is "you could clear screen!" with them.

And would I learn the language differently for academics and for fun?
 

adi_vastava

Code Game Code F**K
Adept
Feb 23, 2010
884
25
42
>>You say though c is difficult, still better to learn that first for whatever reasons. Again you say "A book on C" is an overkill an he may take a step back because of that.

Don't you find that contradictory?

Not at all, I was suggesting him to, do learn C at first place but at same time don't make it a lot complex. Read the basics first and gradually move to more complex topics. SO I suggested that as a light reading instead of reading python read let us C and then read some intermediate/advanced books on that.

>>Could I ask you a few questions you could answer from "Let us c"

Sure, Let me see If I can still remember this from the book (I think I read it 10 Yrs back, 3rd edition :D )

>>What's the size of an integer?

I think "let us c" (read book) do not talk about that. Nor they talk about any platform dependent thing, which I agree is not good but then not a bad practice.

>>What are the different argument passing mechanisms in c?

I think the book does talk about them.(in chapter functions)

>>Is array a pointer? Can arrays be passed? If yes, by value or reference?

>>Is the following code considered cryptic?

>>while(*t++ = *s++)

>> ;

>>assume s,t are char * What's the equivalent?

Not in this book, though probably not even in ritchie. but again has nothing to do with bad practice and his pointer in C does refers this and more.

>>What do you keep in .h file and what in .c file?

This does falls into the category but I believe a starter can do without it, did I say just read let us C, no I didn't I said read it first and then move to some good book

Now let me ask you few thing,

do they tell you that in c++ you can call a function of a class with a pointer of class initialized with null and there will be no crash provided that you do not touch any member variable.

Do they tell that actually *this* pointer get passed through ECX register

Do they tell that when you have some read only variable, how compiler actually put the variable in a read only .rdata section on which loader applies read only page protection attributes.

does any of the book talk about containing_record macro, used a lot in real kernel programming and is real useful

No they didn’t, why because this is not in the scope of what that book was suppose to cover, as some of it is compiler dependent, some of it is OS specific. In same way let us c is a very beginner book which one should read to start things and then move on. OP does not want to read that fine, no problem , but why cursing it man?

Additionally I looked at the link you posted & may be I missed but I didn’t found that poster stated that he got the code from xyz book.

>>The best I remember is, one of the advantages of using structures is "you could clear screen!" with them.

Really :rofl:, which one kanitkar or balagurusamy

>>And would I learn the language differently for academics and for fun?

Yes you do, in fact it’s always the objective which defines your learning. I learned x86 in college but never used it in my professional life apart from few crash dump analysis or sometimes when I was suppose to reverse engineer MS file systems. But now days I am working completely on it, I have recently read it again, with a totally different mindset. In college it was understanding how assembly works and but now its how MS compiler and loader used it and how can I identify a pattern in generated assembly.

I agree with you for some parts but you cannot claim a book is bad just because it do not contain what is there in other books. and I have not read the second book you mentioned but a glance on amazon can easily tell that it covers a lot more than Let us C. So it probably is targeted for different audience altogether. A normal graduate/post graduate, Let us C is a definite pick, an engineering student obviously not.

P.S.: Though not intended, I believe you took it personally, I was just trying to help OP who I believes is a self-learner. So nothing personnel at all. Additionally if OP wants to learn C, why should we bang our heads. we already got enough things to do :).

I hope I make it clear this time.
 

haraakiri

Active Member
Adept
May 28, 2009
814
24
31
39
adi_vastava said:
Not at all, I was suggesting him to, do learn C at first place but at same time don't make it a lot complex. Read the basics first and gradually move to more complex topics. SO I suggested that as a light reading instead of reading python read let us C and then read some intermediate/advanced books on that.
:)

>>What's the size of an integer?

I think "let us c" (read book) do not talk about that. Nor they talk about any platform dependent thing, which I agree is not good but then not a bad practice.
Try to write a program to set a bit, turn off a bit , toggle a bit or something similar. You will get wrong programs by reading just let us c. IMO bad practice of using magic nos.

>>What are the different argument passing mechanisms in c?

I think the book does talk about them.(in chapter functions)

And the discussion there is completely wrong, leading to lot's of bad practices.

>>Is array a pointer? Can arrays be passed? If yes, by value or reference?

>>Is the following code considered cryptic?

>>while(*t++ = *s++)

>> ;

>>assume s,t are char * What's the equivalent?

Not in this book, though probably not even in ritchie. but again has nothing to do with bad practice and his pointer in C does refers this and more.
Absolutely wrong. They are discusses in Ritchie. That's why , you need to read that book first.Using equivalent is the biggest bad practice according to most experienced c programmers(like Linus Torvalds, you might be very fond of him :))

And what Let us c discusses about pass by mechanisms in c is just plain wrong Read Ritchie to get the right answer. :bleh:

>>What do you keep in .h file and what in .c file?

This does falls into the category but I believe a starter can do without it, did I say just read let us C, no I didn't I said read it first and then move to some good book
In my opinion completely wrong again. Every c programmer need to know that. You need to understand importance of modularity from the start.

Now let me ask you few thing,

do they tell you that in c++ you can call a function of a class with a pointer of class initialized with null and there will be no crash provided that you do not touch any member variable.
That's wrong. That's called "undefined behaviour" in c++.Read Bjarne's book

Do they tell that actually *this* pointer get passed through ECX register

Do they tell that when you have some read only variable, how compiler actually put the variable in a read only .rdata section on which loader applies read only page protection attributes.
Wrong again, that's platform specific. Compiler is free to choose the best approach. For eg changing a const char * to char * and assigning to is undefined behaviour. It works differently for eg on platform where memory protection exists and where it doesn't.

does any of the book talk about containing_record macro, used a lot in real kernel programming and is real useful
That's not Standard C. Do you actually understand what's standard c and what not? That's why you need to know size of int is platform dependent and a book should tell that.

No they didn’t, why because this is not in the scope of what that book was suppose to cover, as some of it is compiler dependent, some of it is OS specific. In same way let us c is a very beginner book which one should read to start things and then move on. OP does not want to read that fine, no problem , but why cursing it man?
Books need to tell what's standard c, that's where you know what's portable, what's not. You as an os kernel developer need to know. You need toi keep platform specific details seperated from platform independent.

I am not cursing anybody, please. If it feels that way, I humbly apologize. That wasn't my intention. I am just trying suggest that reading a good book is better.

Additionally I looked at the link you posted & may be I missed but I didn’t found that poster stated that he got the code from xyz book.
That's almost balaguruswamy way of doing things. You might disagree. No issues.

>>The best I remember is, one of the advantages of using structures is "you could clear screen!" with them.

Really :rofl:, which one kanitkar or balagurusamy
That's kanetkar's book. :) There are 10 or so points on advantages on structures. I am not sure whether that still exists in the newer edition, but believe me there are many more jokes in that book. Perhaps we need to start a seperate thread on it!

>>And would I learn the language differently for academics and for fun?

Yes you do, in fact it’s always the objective which defines your learning. I learned x86 in college but never used it in my professional life apart from few crash dump analysis or sometimes when I was suppose to reverse engineer MS file systems. But now days I am working completely on it, I have recently read it again, with a totally different mindset. In college it was understanding how assembly works and but now its how MS compiler and loader used it and how can I identify a pattern in generated assembly.
You might be right, in my case it was never different.

I agree with you for some parts but you cannot claim a book is bad just because it do not contain what is there in other books. and I have not read the second book you mentioned but a glance on amazon can easily tell that it covers a lot more than Let us C. So it probably is targeted for different audience altogether. A normal graduate/post graduate, Let us C is a definite pick, an engineering student obviously not.
I have read both books, I feel they cover pretty much same topics. But anyway if yo u scanned in on amazon, perhaps you are correct.

P.S.: Though not intended, I believe you took it personally, I was just trying to help OP who I believes is a self-learner. So nothing personnel at all. Additionally if OP wants to learn C, why should we bang our heads. we already got enough things to do :).

I hope I make it clear this time.
I have learnt a lot here on TE about hardware, I won't mind anybody correcting my wrongs. You are always welcome to do that and I assure you I will not take it personally.

You have taken a good amount of time to answer my questions and read the other thread I mentioned, I really appreciate your effort. Would be looking forward to your insightful replies. Healthy arguments are one way we can improve ourselves. :)
 

blufox

Well-Known Member
Adept
Jun 2, 2009
360
70
67
Mountain View, CA
Get K&R and throw Kanetkar's all books in dustbin. Same goes for Schildt's books.

Al Kelly and Ira Pohl is what I started with and then switched to K&R.

K&R is to the point with no bullshit filler text, so get it.

Do not forget that appendix in K&R is godly, do not miss it.

Kanetkar does not even understand what is Ansi C forget anything else.

PS:- Yeah I once attended Kanetkar's C seminar and was so disappointed with his replies and his limited C proficiency.
 

rohan-04

New Member
Disciple
Apr 29, 2009
89
0
0
I am learning the languages form academics point. Ok so since i want my basics to be good i should go with Let us C? or should i go with the K&R book? I am confused now! :S
 

adi_vastava

Code Game Code F**K
Adept
Feb 23, 2010
884
25
42
>>Try to write a program to set a bit, turn off a bit , toggle a bit or something similar. You will get wrong programs by reading just let us c. IMO bad practice of using magic nos.

Not sure whether I read it from that book or not, but than hard coding should always be avoided.(on an exception I always use 2 instead of using sizeof(WCHAR) :), some may consider it as bad practice but their are reasons to do it )

>>like Linus Torvalds, you might be very fond of him )

Nah, I am a windows guy ;), so you can imagine

>>Wrong again, that's platform specific. Compiler is free to choose the best approach. For eg changing a const char * to char * and assigning to is undefined behaviour. It works differently for eg on platform where memory protection exists and where it doesn't.

Come on, Man, If you read my post, even I said that -> "as some of it is compiler dependent, some of it is OS specific.", So what do you mean by wrong again, try to get the point. Please.

I do not consider "let us c" as a proper C book, leave good and bad book debate aside. But its a starter book, being taught few MCA batches years back in my college & I found that a majority (though not all) which came from B.Com background, picked well when I throw "let us c" first instead of "The C programming language".

>>Books need to tell what's standard c, that's where you know what's portable, what's not. You as an os kernel developer need to know. You need toi keep platform specific details seperated from platform independent.

Actually you can not port code from kernel driver from windows to other OS (with very few exception), their are big architechural difference, the interface which one is suppose to follow in windows is entirly different in other OSes & than the APIs exposed. So In windows kernel, you write code which works well in windows version supported, that is it.

>>I am not cursing anybody, please. If it feels that way, I humbly apologize. That wasn't my intention. I am just trying suggest that reading a good book is better.

Actually you said "These are pretty bad and you will pickup lot's of bad practices", which I believe is a generalization. And I avoid generalizations and personnel hit, especially in open forums. What I found bad in let us C is that he wrote all specific to DOS which, was obsolete 10 years back. It was so platform specific that it would be better to rename it as C programming in DOS. But I believe the author never wrote it for standard C, he purposely picked DOS and C probably considering/evaluating the target market at that time and no doubt he was successful in that.

So this is how I abuse things when I have to (I usually don't).

>>That's not Standard C. Do you actually understand what's standard c and what not? That's why you need to know size of int is platform dependent and a book should tell that.

Another personnel hit :), I may not be a champ in standard C but for sure I can tell you that K&R is not a standard aka. ANSI C book.

>>That's almost balaguruswamy way of doing things. You might disagree. No issues.

I just don't know java so obviously could not pick the book, I can surly take your words on it.

>>Healthy arguments are one way we can improve ourselves

+1
 
  • Like
Reactions: 1 person

haraakiri

Active Member
Adept
May 28, 2009
814
24
31
39
If you want your basics to be right, there's no way you could go with kanetkar, as blufox too suggested. IMO Ivor Horton's "Beginning C" is as simple as Let us C but much better you could go with that. Anyway my recommendation would Kelly Pohl's book and follow it up with K&R. You could download ebooks of these and decide for yourself. If you only need to score well in your exams, without learning much anything is okay including Let us c. And sorry for confusing you:ashamed:
 

adi_vastava

Code Game Code F**K
Adept
Feb 23, 2010
884
25
42
rohan-04 said:
I am learning the languages form academics point. Ok so since i want my basics to be good i should go with Let us C? or should i go with the K&R book? I am confused now! :S
I am sorry confuse you, if you ask me, all I can tell you is that getting good number is different than actually understanding the language.

you want to learn the language, program a lot,

>>how will you do that, pick k&r first(cause its very cheap, under 100), see if you can get things. if so skip "let us C", and continue with the other book as mentioned. If you are not able to get things from k&r, you may want to read other sources.

Now for your academics, it depends on how your system is? Which is your text book and which book your teacher prefers. Its better to write in exams, what is written in their preferred book so asking them for it should not hurt.

I once tried writing a whole 15 marks program in DS paper my way, though I was 100% sure that was a correct though not standard implementation. My teacher deduct 10 marks for that as they'll not read your whole program(they don't have time for that bro). They'll see if it matches with what they know and give you marks accordingly.
 

rohan-04

New Member
Disciple
Apr 29, 2009
89
0
0
The thing is i dont just want to score well in my exams i want to know the language and be good at programming in it, So i think ill go with your suggestions and get those books. Thanks alot.
 

adi_vastava

Code Game Code F**K
Adept
Feb 23, 2010
884
25
42
I'll again want to enforce one point,

you want to be good at programming in a language, than

*program a lot*, there is no match for what you'll learn from your experience. No book can teach you that. period. And this is why experience counts.