C Resources

Back

Frequently Asked Questions about the C language

Web-based tutorials

Interactive Internet Resources

Recommended books

Free Compilers

Commercial Compilers

Generally Useful C Sites

Frequently Asked Questions about the C language

The comp.lang.c FAQ list can be found online at http://c-faq.com - the book version (see Recommended Books) contains considerably more material, but of course the online version is free.

An attempt is being made to set up a C wiki with authoritative content. This site is developing nicely, despite a recent lengthy outage, and is steadily building up some useful C-related content. The URL is http://clc-wiki.net/wiki/ - why not get involved in making it even better?


Web-based Tutorials

There are plenty of C tutorials on the Web. Most seem to be written either by inexperienced C programmers who wish to pass on their lack of experience to others (such tutorials should be avoided completely), or by people who make the basic assumption that "obviously my readers will be using the same platform as me". This latter category is harder to dismiss, since some people aren't really fussed about learning the C language per se; they only care about using C on one particular platform. For such people, if they can find a good tutorial that devotes itself to their platform, that's great. But when I learn about a new tutorial site, I'm afraid I can't always afford the time to check the site out in detail, so I generally wind up looking for obvious errors (of a kind that a C expert would either not make at all or would at least quickly correct), or platform dependent advice. If I find either, I deduce that the tutorial, for whatever reason, is not suitable for teaching the C language itself, and read no further.

It's quite difficult to pass muster when the standard is so strict, but two sites do meet my criteria of correctness and portability.

  • Steve Summit's excellent, and rather gentle, tutorial can be found at http://www.eskimo.com/~scs/cclass/; the serious C student will benefit most from this tutorial if he or she has a copy of "The C Programming Language", 2nd edition, by Kernighan and Ritchie (see Books, below).
  • Tom Torfs takes a rather more austere approach; this doesn't suit everybody, but many people have found it extremely helpful. His tutorial can be found at http://cprog.tomsweb.net/cintro.html

Interactive Internet Resources

The two most important ways of getting help with C interactively on the Internet are Usenet and IRC. (I mean "interactive" in the sense of being able to ask a question in your own words and getting an answer from a real live human.) If you're learning C and don't have a teacher to guide you through the language, IRC and Usenet can be handy places to get some quick advice. Beware, though: neither is a substitute for a knowledgeable C teacher (alas, these are rare), or a really good book on C.

Usenet is a batch-driven environment, in which you subscribe to a news service (this is normally provided freely by ISPs as part of your Internet "package"), and can post articles to that service. The best Usenet "newsgroups" on which to get C help are comp.lang.c (fast and furious) and comp.lang.c.moderated (slower, but considerably less furious!). When using Usenet, be patient. It takes time (sometimes as much as a day or two) for your article to be propagated on news servers around the world. Also, please remember that nobody is obliged to help you. In general, you are more likely to get help if the answer to your question is (a) not in the FAQ, (b) not one of those that crops up every other day but doesn't seem to have made it into the FAQ, and (c) actually about the C language, rather than some particular platform.

Please read the comp.lang.c welcome notice before diving too quickly into the newsgroup. This notice, as well as being on the Web, is posted in the newsgroup on a regular basis. Thank you.

IRC (Internet Relay Chat) is more immediate. If you are lucky, you can get a good answer to your C question within a few seconds of asking it. A considerable amount of C expertise lurks within IRC, although perhaps not as much as can be found in comp.lang.c; unfortunately, it is in the nature of a real-time forum that the quality of advice you get very much depends on who is around (and awake!) at the time. Also, IRC channels are generally far less formal than the Usenet "equivalents", and can sometimes get clogged up with useless discussions of subjects unrelated to C (mind you, that happens on Usenet, too, although perhaps not to such a great extent).

Freenode's ##c channel is a bit fierce, and you have to be quite quick on the /ignore, but - the last time I checked, at least - there was some good expertise there.

The #c channels on Efnet and Dalnet (if you can get in, which I generally can't) are also well worth a look.

In both Usenet and IRC, judge the quality of the advice you get by the usual common sense criteria: (1) does your advisor take the time and trouble to make his or her thoughts clear, so that you can actually understand what he or she says? (2) does your advisor back up his or her advice, when necessary, by referring to the language definition or to K&R (see the Books section, below)? (3) is your advisor respected by others in the channel, particularly by the ops?

Why these particular guidelines? Well, firstly, if ur tld abt stff in hvly abrvtd frm, you may easily misunderstand the advice, even if it's good advice. A good advisor will not risk such ambiguity. Secondly, a good advisor will be aware of the language definition (the ISO C Standard), and will refer to it when it is appropriate. Thirdly, a good advisor tends, over the course of a few months, to acquire a good reputation (whereas, conversely, a poor advisor tends to get a poor reputation).

Be ready to show your code. If you can't fix your problem with the source code in front of you, it's unlikely anyone else can fix it blind. But before you do show your code, you should reduce (a safe copy of!) your program to the minimal possible complete program that demonstrates your problem. Don't waste other people's time with extraneous junk. Once you've done that: on Usenet, paste the source code straight into the article (don't use "attachments" in text-only newsgroups such as comp.lang.c; on IRC, though, pasting more than a couple of lines of inline code is considered ill-mannered, because vertical space is at a premium in a real-time environment. So, if you want people in IRC to help you, use a "paste site"; if you visit such a site, you will discover that you can paste your code into a dialog and press a "submit" button; this will copy your code to a Web page, and will display the URL of the Web page for you. The idea is that you then tell the people in the channel which URL to look at; they can then look directly at your code, and then they can start to help you. Here are the paste sites I know about:

Finally, please remember that those in Usenet and IRC who answer your questions are not under any obligation to you. (If anything, the opposite is true.) Nobody has to answer your questions. If you are polite and not too dense, however, they are generally quite willing to help.


Recommended Books and Reference Material

There are a great many books on C. Many are of low quality. Some are rather better. I haven't bothered mentioning the low quality books here.

Alas, I cannot read every book on C. I don't have time. So some of the books mentioned below are recommended purely on the basis of a 5-minute glimpse in a bookshop, or on the basis of their reputation amongst C experts. I have marked the books I've actually read with a (Read It) note.

If you have never programmed before, and would like to learn C as your first programming language, I suggest either of the following two books:

C Programming: A Modern Approach, K.N.King, W.W.Norton & Company, 1996. ISBN 0-393-96945-2

C: How to Program, 5th Ed. Deitel, H.M. & Deitel, P.J. Prentice Hall, 2007. ISBN: 0-13-240416-8 (Read it)

If you are already an experienced programmer, but just haven't yet learned C, you will appreciate the briefer approach of Brian Kernighan (silent 'g', by the way), and Dennis Ritchie. Kernighan is the 'K' in AWK, and Dennis Ritchie wrote the C language itself. The book is very short (272 pages including the index), but its information density is colossal. This book teaches you more about C than many books four times the size:

The C Programming Language, 2nd Ed. Kernighan & Ritchie. Prentice Hall, 1988. ISBN 0-13-110362-8 (paperback), or 0-13-110370-9 (hardback). (Read it)

For reference purposes, I generally use The C Programming Language, affectionately known as "K&R", which has an excellent reference section at the back. Nevertheless, several excellent reference books exist; and, of course, the language definition itself is the ultimate reference.

C: A Reference Manual, 4th Ed. Harbison & Steele. Prentice Hall, 1995. ISBN 0-13-326224-3 (Read it)

I am told that a 5th edition of Harbison & Steele was published in 2002, but have not seen it specifically recommended. (But it's almost certainly well worth getting.)

The Standard C Library. P.J.Plauger. Prentice Hall, 1992. ISBN 0-13-131509-9

C Programming FAQs Steve Summit. Addison-Wesley, 1996. ISBN 0-201-84519-9 (Read it)

ISO/IEC 9899:1999 ISO. Available from various national standards bodies. (Read it)

The following books discuss various aspects of programming in the C language, but are neither tutorials nor references:

C Traps and Pitfalls. Andrew Koenig. Addison-Wesley, 1989. ISBN 0-201-17928-8

Expert C Programming: Deep C Secrets, Peter van der Linden, Prentice Hall, 1994. ISBN 0-13-177429-8 (Read it)

Problem Solving And Program Design In C, 2nd Ed. Hanly & Koffman. Addison-Wesley, 1996. ISBN 0-201-59063-8

Algorithms in C, 3rd Ed. Robert Sedgewick Addison-Wesley, 1998. ISBN 0-201-31452-5

C Unleashed, Heathfield, Kirby et al, Sams Publishing, 2000. ISBN 0-672-31896-2
I couldn't resist including this on the list, for obvious reasons. (Wrote it)

Software Solutions in C, ed Dale Schumacher, Academic Press, 1994. ISBN 0-12-632360-7
Alas, this book is out of print. If you see a copy, grab it. It has chapters by a number of C gurus, including Doug Gwyn and Henry Spencer. (Read it)

Programs and Data Structures in C, Leendert Ammeraal, John Wiley and Sons, 1992. ISBN 0-471-93123-3 (Read it)

Numerical Recipes in C, 2nd edition, by Press, Teukolsky, Vetterling, Flannery, Cambridge University Press, 1992. ISBN 0-521-43108-5
Great recipes, but the C is dreadful. The authors prove the old maxim that it is possible to write Fortran programs in any language, alas. Be warned. (Read it)

You may also find the following sites useful:

Jack Klein's site contains a more detailed discussion of some of these books.
The Association of C and C++ Users carries a large number of reviews of C books. Although I don't always agree with their assessments, in general the reviews are well-balanced and thoughtful.

Freenode ##c's wiki also contains a useful list of C books.


Free Compilers

It should be remembered, when selecting a C compiler, that many C compilers also provide a C++ feature. Thus, you may well find yourself downloading a "C++ compiler", and be wondering whether it will actually support the C language. The answer is: "probably". I can certainly assure you that Borland C++, Microsoft C++ ("DevStudio"), and gcc are all very good C compilers. Just remember, when using a compiler that can handle both languages, to tell it (as firmly as you think necessary) that you are using C, not C++. Generally, if you're using a typical desktop PC operating system and compiler, simply using a .c extension on your filename is sufficient to convince your compiler that you really do want C, not C++.

  • King of the free compilers, gcc is not just free, but also open source. And it's an extremely good compiler, used by hobbyists and professionals the world over. (I've used gcc on eight different client sites over the last six years or so.) This is my compiler of choice.
  • The command line version of the superb C compiler Borland 5.5 is, believe it or not, free of charge.
  • Also from Borland (this time from their "museum" site), is the not-quite-conforming (but close enough) Turbo C 2.01. A complete C compiler in about one Megabyte. And yes, lots of commercial programs were written with this program, in its day. And yes, it works just as well as ever it did back in 1989. (Except that it's a bit quicker nowadays.) Works fine on ancient kit (no surprise there), and I still use it occasionally on modern boxes, without problems.
  • D J Delorie's gcc port for MS-DOS is quite a nice compiler, although I had a certain (small) amount of hassle installing it. 80386 or better required.
  • Watcom C
  • MinGW (Windows port of gcc)
  • The Digital Mars C compiler
  • lcc, an ANSI C compiler.
  • Microsoft C is now available for free download, if you don't mind using the command line.

If you can't find what you're looking for amongst that lot, have a look at the Freenode ##c software page, which contains even more links to compilers and other C software.


Commercial Compiler Vendors

These guys should do their own advertising, so I won't do much more than link to their base pages here.


Generally Useful C Sites

The Lysator C Page
DinkumWare
DinkumWare's online interface to EDG C99
GNU
W Richard Stevens' Home Page
Beej's Sockets Tutorial
Eric Raymond's "The Art of Unix Programming"
Mikey Lee's guide to optimising C programs
An excellent C reference guide written by no less than Brodie and Plauger
Eric Giguere's Guide to Reading C Declarations
A Pointer Tutorial
Function Pointer Tutorial
A list of identifiers to avoid in your C programs
C - The Complete Nonsense (a Schildt critique)
The Annotated Annotated ANSI C Standard (another Schildt critique)
C - Infrequently Asked Questions
The International Obfuscated C Coding Competition
"The C Programming Language" Home Page
Dennis Ritchie's Home Page
Brian Kernighan's Home Page
Clive Feather's Home Page

The Freenode #c IRC channel Home Page

Morris Dovey's Home Page
Jack Klein's Home Page
Ben Pfaff's libavl page
Ben Pfaff's C scribblings