tags:

views:

901

answers:

11

I'm looking for a series of C problems (with solutions) that I can use to build my C skills. I already understand the basics of the language, the syntax, and the semantics. I am looking for a series of problems that will help me hone my skills, not a set of simple questions that you'd see in an introductory programming class.

+5  A: 

Build libraries that implement sophisticated data structures, like binary trees, dictionaries, and such.

Robert Harvey
+1  A: 

One of the best ones - http://users.powernet.co.uk/eton/kandr2/

Secko
That site is no longer maintained, the active site is http://clc-wiki.net/wiki/K%26R2_solutions
Robert Gamble
+9  A: 

And don't forget code-golf.

You probably want to respond only to challenges (questions) that have at least 10 upvotes.

DigitalRoss
+1 , though I'm tempted to scratch out the word 'Ping' on my dusty set of real clubs and replace it with 'Perl'. Still, fun to work on the problems with C, especially lasers.
Tim Post
Right, on SO in particular code-golf is about more than just short programs, it's also a general forum and a place for everyone to advance their skills.
DigitalRoss
+4  A: 

Write a compiler. It doesn't need to be complex or even complete: you can make up a simple language (a subset of lisp?) and then write a lexer for it. Make sure you start by laying down the formal grammar. You will touch memory management, pointer arithmetics and other neat C stuff.

I learnt a great deal about automata and compiler-design by writing a simple YAML parser in C++.

wilhelmtell
That's about as good as learning C by writing an operating system. Sure I did it to learn C, but I wouldn't recommend such extreme pain to anyone(course, I didn't know all the semantics and such of C either when I started). Any big complex project will help you learn C though
Earlz
No, my point is to just start on something. I happen to be interested in compilers, parsers, interpreters and such. OS, games, text-editors -- they can all be big and daunting. The trick is to start. Make it as small as you can, even an incomplete subcomponent of a large porject. If you're dealing with what fascinates you then you'll do fine, and you'll even enjoy yourself.
wilhelmtell
+7  A: 

You might try solving some of the problems on Project Euler. The first few are pretty simple, but they get very challenging very quickly. I think it's a lot of fun trying to come up with the shortest code or highly optimized code to compute the results (though, I generally use C++ or Python, not C).

One advantage the Project Euler problems have is that they aren't just language-centric; they're problems that really make you think hard about how to develop an elegant solution to difficult problems.

James McNellis
+1 for the nice suggestion. However, Project Euler isn't what the OP is looking for, because he wants problems with their solutions, and PE doesn't show the solution until you've solved the problem yourself.
Moayad Mardini
Well, Project Euler does tell you if _your_ solution is correct, and if you search Google you are bound to find solutions to many, if not most, of the problems in a variety of languages.
James McNellis
+2  A: 

Try out Dennis Ritchie's book on C programming language. The book has quite good problems and also reading it is a joy :) For more challenging problems you can go to Bitwise Programming contest

mkamthan
A: 

Knuth's repository of bitwise stuff might help in the noble pursuit :)

http://www-cs-faculty.stanford.edu/~knuth/fasc1a.ps.gz

Arvind
A: 

Ruby Quiz has 156 problems with solutions. But in Ruby, not C. See the ruby-lang mailing list for more after James stopped being Ruby quiz master.

mcl
A: 

Practice code Katas, language does not matter that much. Trying to solve Katas you allready did with another language is usually quite efficient to learn a new language.

kriss
A: 

You could always visit Freshmeat, find a few projects that interest you and look at their bug tracker. Grab the code and try to fix a few of the problems.

This helps open source while also helping you to get used to jumping in to someone else's code with debugging goggles on.

Tim Post