tags:

views:

731

answers:

8

I'm primarily a c#/.NET programmer, but the hobby project that I am about to take on will involve coding in c.

I know that there is a ton of c code out there, but its very hard to separate a well structured c project from a badly structured project if you did not "grow up" with the language. Can anyone point me toward a newer, non trivial (but not enormous) project that is considered a good example of how to structure c code?

Edit

If you cannot find a project, feel free to discuss in words how you think a c project should be structured.

+3  A: 

This is completely anecdotal, but I've heard that the SQLite project is considered good code.

Andy Gaskell
It's a nice API at least :)
Skurmedel
+5  A: 

Check out git source code: http://github.com/git/git/tree/master

Piotr Czapla
125,000 lines of code for a new C programmer? Are you sure?
Norman Ramsey
It is all about the structure and the style. You don't have to read every line though.
Piotr Czapla
+5  A: 

I consider Steve Dekorte's IO language implementation to be a good example for clean and pragmatic modern-day C.

earl
I agree, it's really nice code. I like it and I can understand it ;-)
Friedrich
+9  A: 
Norman Ramsey
+1 for Lua. I was pleasantly surprised when I took a look under the hood to see if it was going to be acceptable performance and quality wise for an embedded software project I was on.
patros
Git has consistent style and structure so it is good material to learn. You don't have to ready every line of it!
Piotr Czapla
@Norman looks like the book is available on Safari. I must have skipped it over because it is 13 years old (assumed it wouldn't be "modern code"), but I'll check it out on your recommendation; thanks!
Giovanni Galbo
125,000 lines of GIT versus 17,000 lines of Lua doesn't make much diference in this case, since he will not (probably) read every line...
Alceu Costa
@git advocates: How will the OP know where to get started? Any thoughts?
Norman Ramsey
+1  A: 

How about:

"The C Programming Language", 2nd edition, Kernighan and Ritchie

Answers to Exercises

http://users.powernet.co.uk/eton/kandr2/

+1  A: 

The following book (with code examples) could ease your paradigm shift a bit:

Stephen Kochan

Programming in C, Third Edition

http://www.kochan-wood.com

+1  A: 
amaterasu
+1  A: 

The SVN project is written entirely in C and it is well maintained: consistently styled, good comments, low code smell. I recommend perusing it.

jeffamaphone