What does good, modern c code look like? [closed] - c

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
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.

Dave Hanson's C Interfaces and Implementations is a very well-crafted library of about 7000 lines of code. The book is great if you can afford it.
The implementation of the Lua programming language and libraries is about 17,000 lines of C code and is very well done but quite sophisticated in places—compilers and garbage collectors are not so easy to understand without background in those fields. But the code is beautifully engineered.
Git is over 125,000 lines of code. I can't recommend that anyone study it as an example of how to engineer C code. Just the design and public interfaces, let alone the implementations, are hard to understand—which is why there are so many git tutorials.

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

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

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

How about:
"The C Programming Language", 2nd edition, Kernighan and Ritchie
Answers to Exercises
http://users.powernet.co.uk/eton/kandr2/

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

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

C: A Reference Manual contains a variety of example code usage, with implementations centric to Standard C; A definite document to look into, perhaps along with the C Std.

Related

Looking for a good GUI library for C [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
As the title says, I am looking for a good library for the C Programming Language.
The GUI library should be really popular. I'd also appreciate if there are popular forums on the Internet where I can ask professionals for help. And I definitively need a good book about the library. If it's possible it should be cross-platform but I can live without that... I guess ;)
The only library I know for C so far is GTK. It sounded really well to me but neither did I find any good book (I've actually seen only one book about GTK and I don't know if it's good or bad cause nobody posted a review) nor did I see anyone using it except 2 guys on You-tube with their impressing amount of 2 videos! >.< .
The really important thing for me is that it should be popular... I don't want to sit here, learn how to use this library and in a year or two nobody uses it any more.
I hope you guys can help me finding a library :)
GTK+ is hugely popular and is used extensively. It's the best choice if you want cross-platform GUI development in C alone. There are plenty of books around, though they're a bit outdated (but most of it still applies). You can find up to date tutorials and full API documentation at the GNOME project website.
GTK is the most popular GUI library in C you can find.
Have you tried amazon? There're plenty of books. It's hard to believe that all of them are bad.

How to start building a programming language in C? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I really would love to go through the experience of building a compiler, lexer, and so on using C, however I havn't found a single resource on creating one. I've read the book about creating your own language using Ruby, but it just talks about how C is the best option, and won't tell you where to go from there.
Is their any nice resources for building a language using C? I don't care how long it is, I just want to know how to build one.
One of the nice things about compilers/interpreters is that it doesn't really matter what language they are written in. In the final stage they will just be an executable on someone's machine.
That being said while writing my compiler (something I am currently doing) I have used several books that have been extremely helpful:
Compiler Construction by Niklaus Wirth
Compilers Principles, Techniques, and Tools by Jeffrey Ullman, Alfred Aho, Ravi Sethi
The Wirth book will walk you through all the stages of creating a compiler for a language called Oberon-0. It also has the entire source code for his finished compiler, so you can play around with it on your own machine. The compiler itself was written in Pascal (something else that Wirth created).
The Dragon Book has really good information and examples in C! This may be what you are looking for, but as I said above, the language you write the compiler in isn't all that important.

I need some new blogs to help learn my new language (it's C) [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm a BIG blog reader. I can't stop reading blogs. Blogs helped me find this site (in particular Jeff's blog). However I've come to realize that all the blogs I read deal with one language.
Coding Horror
Fabulous Adventures In Coding
Jon Skeet's Blog
Scott Hanselman's Blog
Did you guess the language?
Well now I'm learning C and using GTK (The Gimp Tool Kit). I can't really find any bloggers who actually blog about C like Jeff, Eric, Jon, or Scott do about C#. I need the blogger to be active, and it'll help if he has a sense of humor.
I think that the C equivalent of a blog is called a book. Step away from the internet browser :-)
I go back to the 90s with C. I'll write more if people will read.
That thing about books was explained to by a friend (jacox): "You can't grep a dead tree."
You may want to keep an eye on this fellow named "Jibz" who recently started up:
http://www.hardtoc.com/
C is not as hip as C# and friends. You will not find many blogs about it.
The only blog I can think of where I got some relevant C info is, There Is NO Box.
I'm really sorry, but I've made the same search, and the result of my search was sad but expected. C# is a hot topic these days in development circles compared to C [*].
I'd love to be proven wrong, but there is simply nothing in the C world equivalent to the blogs you've mentioned.
[*] I am not criticizing C, It has been my bread and butter for the last 3.5 years, just stating the reality

Great C tutorial? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I really want to learn C. What would be a good tutorial?
The C Programming Language (often referred to as "K & R") is almost universally considered to be the best resource for learning C.
While "The C Programming Language" is certainly a great book and a very good introduction to the C language, it has several drawbacks:
It is somewhat dated, the 2nd edition (the last one) covers only C89 which is now 20 years old. While C99 (the current Standard) isn't universally supported, there are a number of features from it that are supported by many implementations and exposure to them is useful.
It isn't comprehensive. It doesn't cover many of the standard library functions in any detail and certain intricacies are not explored in depth.
The text assumes you are already an experienced programmer and has a very terse style which doesn't work well for everyone.
If you are looking for a more beginner-friendly, comprehensive, or up-to-date book, I would strongly recommend C Programming: A Modern Approach, 2nd Ed. It covers every aspect of the language and the standard library in depth, including C99, and is extremely well-written. While the list price is rather high, it usually isn't difficult to find a copy for around $60 USD.
The Official GNOME Developer's Guide: http://oreilly.com/catalog/9781593270308/
Tutorials might be semi useful at first, but I always learned a language by actually developing useful code.
I'd recommend you check out some of the Gnome Love Projects.
They are generally smaller tasks for people who are interested in joining the gnome development community. They will help you get used to the dev environment, and submitting patches and the style & conventions they use. Most will teach you something you didn't know about C also.
The C book is a good and free ebook.
Here is one resource. http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/
You may refer C Programming Notes meant to supplement K&R.
It's more a faq than a tutorial, but it is quite useful: C - faq.
Concerning Gnome programming: Gnome guidelines
And here are some tools every C programmer needs:
gcc
gdb - debugger
Valgrind
gprof - Profiler
Always avoid tutorials (written by kids, for kids)
Read KR
I would seriously advice you to check out Bruce Eckel's freely available "Thinking in C", which is a flash-based introduction to the C family of programming languages:
A Flash-based audio-visual seminar to introduce you to the fundamentals of the C language which will help you move on to C-based languages like C++, Java and C#.

Interview questions to assess Linux C programmers [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I'm not quite a C programmer and I'm going to interview a guy with 3 years experience in C in linux. In his CV, he says he is quite experienced with C programming.
So my question is if you are going to interview this "C linux" guy, what question or questions would you ask to make sure that this guy is competent? By the way,
I expect you give me the answer as well :-).
Thanks in advance.
If the candidate really knows his stuff (C Linux programming) he'll catch you pretty quickly, but anyway, here are a few pointers to topics you should investigate to prepare questions:
POSIX concepts
Standard C library (libc), ANSI C
Debugging and profiling tools: gdb,
valgrind, strace, etc
Linux/UNIX system calls: sbrk,mmap,fork,etc
Threading
(Insert your favorite pointer question here)
The GNU toolchain: gcc,ld,as,automake,autoconf, etc.
Classic Linux utility C/C++
libraries: glib,qt, etc.
Don't simulate knowledge you don't have. This will get noticed and this is the image of your company that you are playing with. Candidates may want to find better oportunities.
Be honest with your level of C and ask him open questions about what he finds wonderful in C and Linux, and what he thinks are drawbacks. Let him tell you what were his previous experiences.
Appreciate not his knowledge but his passion.
To be honest I think your best bet is to get someone who is a C programmer in the interview with you to ask questions, you can only really judge competences you have yourself.
If that isn't possible I'd say you should be askind questions that test their knowledge of pointers. an obvious example is to write string manipualtion functions such as strcpy
Favorite:
Ask him where the strenghts of C are...and why he would recommend to use it...maybe you can give him a project example. He has to clarify why C is the right Language for that Job from his point of view.
From my point of view it is very important to know if a Language is really fitting to a project. Not because its your favorite Language...
It is an easy question...
If all you are trying to do is assess his knowledge of a specific language, and you don't know that language, you're gonna fail at evaluating him.
Can you instead evaluate "can this guy program and is he a good communicator" and be up-front with him about your knowledge? Give him a basic question to start with, fizzbuzz or whatever, and ask him to code it in C and give you a C tutorial as he does it. Then do something more complex but C-ey (see other answers for ideas) but still in the context of, "teach me what you know and how this works".
If you frame the question as, "I know (for instance) python and Java, but not C, please teach me" you could end up with a very informative interview. But don't give the poor guy a quiz, you won't be able to give him hints, and he could ace it or flub it with very little correlation with his actual skills.

Resources