tags:

views:

426

answers:

11

I've spent (on and off) the past two and a half years learning C, from books like the k&r. I soon came to the realization that I found the prose difficult to understand, etc. I read the "Teach yourself C in 21 days" book first, but I couldn't even understand it. Now that I have a fair knowledge of how to use the fundamentals of C (this doesn't include pointers/structures, but basic design) I was thinking of reading the Teach yourself C in 21 days again, from pointers, so I can start working on programs. I didn't finish the k&r because of its level of difficulty with it's prose, and some of the exercises. I know a score of people that didn't even use books to learn how to code. So, I'm asking, if anyone thinks is a good idea that I just read the 21 day book, and move forward from there, and read more advanced books like APUE or, expert C programming, and so on.

It's prose is simple to understand, and I really want to get into some projects, where I'd probably realize certain pitfalls for myself.

Could you give me any advice. I'm not in a hurry, but I'm eager to get things done!

+7  A: 

I think you need to start writing some simple programs as soon as possible. Try out what you know and get comfortable with that. Then read a new chapter and try that out.

Writing code brings it to life. Reading books is very dry. I sometimes read a book from start to finish to learn a new language, but that's only because I've learned so many languages by now that I'm not learning the concepts - just the syntax and the odd novel feature.

dommer
+8  A: 

K&R is the best book to learn C from, IMO.

I agree with Peter Norvig: It's not possible to proficient in anything in 21 days. All you're trying to do is get a feel for the syntax so you can start writing simple programs.

duffymo
dwc
And if you've re-read it 10 times and still don't grok it, ask a question on here :).
vg1890
A: 

First of all, if you have no programming experience at all, you can't learn a language in 21 days. You will need at best several months.

On the other hand, if you have programming experience, my opinion is that the best thing you could do is find a "cookbook", like the ones available here. I think Deitel had something like a C cookbook, you should visit their site and see. After you find a book like that, you have to start writing code, all sorts of code, to cover most of the problems that you could encounter while working on a project: memory management/data structures,input/output,networking,etc.

Good luck!

Geo
As I said, I've been learning C on and off for about two years, I know the basics. I just want to get things done
Then go with the cookbook.
Geo
I'm tired of people saying you can't learn a lang in 21 days. FYI I learnt Java in a max of 2 weeks just a short while ago, and now I can build swing apps and simple 2D games. I did have previous programming experience in PHP though
Click Upvote
A: 

K&R is a great book (maybe it is all you need to earn C) all you need is some patience and hard work

Yassir
It is NOT a book a beginner should learn C from.
Geo
+1  A: 

The fastest way to learn is to need to know it. If you've got a problem you need to solve, say, you need to calculate an optimal tournament order for your community's soccer teams, then you will be better motivated to learn how to solve the problem. You will end up encountering one difficulty after another as you learn, but they will always be of the form 'my program doesn't do x' rather than 'i don't really get x'. Each exercise of fixing each shortcoming will teach you new things about the language and how to use them. The added benefit of having a clear goal in mind, with many small successes along the way will keep you energized and provide positive feedback to your learning.

The K&R C book will provide you with just the right tools to approach a problem using C idioms.

If you need some generic ideas for problems to solve, try projecteuler.net, or search for related questions here on stack overflow

TokenMacGuy
+1  A: 

Gosh, 2.5 years seems like an awfully long time! I used to be an instructor with a commercial training company and our C course, which covered the entire language including "advanced" stuff like function pointers, only took 4 days! Which bits are you finding particularly difficult?

anon
I'm sorry if this sounds harsh, but if you need a few weeks to just learn the syntax (after trying for more than two years), then maybe C is not your language (and maybe programming is not your thing).
Mark Probst
Jack BeNimble
Keep at it - you can't be any worse than some of the ex-COBOL programmers I used to have to teach!
anon
What's your programming background, lcamtuf? If you're starting from scratch, you may find it easier to learn another language first, which lets you focus more on the concepts and abstractions of programming. Once you've got that nailed down, you can learn C in a couple of days.
jalf
A: 

Use those 21 days by doing the exercises in K&R.

Pick easy ones first. When you get stuck, you can ask Stackoverflow. ;)

abababa22
A: 

The best way for you to learn C is to put in practice the topics you are learning.

For example if you are going through basic principles like looping and if statements, you can build yourself a little program that simulates the functionality of counting changes on a vending machine.

Once you move on to more advanced topics like pointers and data structures you can build a Logo like program. The user can input each step of the turtle's movement, and you can store that in a linked list. Afterwards you can perform pointer operations on your data structure by deleting, reversing, or adding nodes.

So the idea is to start coding to test what you learned. You will find that some of the time you don't really understand even though it seemed clear in the book. As a good programmer you will end up having to revisit the topics until you actually know it.

Marcel Tjandraatmadja
A: 

Teaching yourself C in 21 days is like teaching yourself handgun safety in 2 minutes. The results of either are undefined, except C lacks a safety or decocking mechanism.

In reality, its going to take the better part of two years to achieve any kind of definition of proficient. You'll gain this by shooting yourself in the foot, repeatedly, while learning from a determination to tackle practical problems using C.

It takes the better part of 9 months to discover blinking, while blinking is a very complex process, C is not always instinctual.

Tim Post
so, I should read wahtever (21 days ) and implement what i should?
Tim Post
@Icamtuf, applying something you read quickly separates texts into two categories.. good or bad. The best way to learn is to do it.
Tim Post
thanks a lot tinkertim
A: 

I think you have to use some libraries like GWT because we learn more when we see how to use the code of other people. And doing some UI is far more motivating than writing console apps. It's funier to manipulate Windows, Button, CheckBox than int, float, double (and not so much difficult).

Nicolas Dorier
+2  A: 

=== From my personal experience and IMO, you are doing it backwards. Start with Hello World! ===

When I am learning a new programming language, I don't just say I "will learn this language because I hear it is good to learn". I need to have a reason to learn the language. Otherwise if I don't have a reason to learn the language I will not learn or retain anything I read about the new programming language.

I learn by doing and that is why I start with doing the "hello world" example.

C is not the most user friendly language and does not have many "easy small programs" that you can implement and do something cool with... and that is why it is hard to get into.

And that is why I think you really need a good motivator to learn C.

Right now the current motivator you have is "I should learn C because people say it is good to learn" ... and I don't think that is enough of a motivator to learn C. One suggestion would be to write a GTK GUI application in C... that will teach you a lot about C and the end product will be something very concrete and cool to point to ( hence a good motivator ).

Trevor Boyd Smith