tags:

views:

147

answers:

6

I last used C professionally around 1997 IIRC. I've used a lot of C++ since then. Now, I find I need to use some C again.

One thing I'm sure of is that I can't just drop the obvious C++ features (e.g. classes) and expect everything to work. There are various less obvious syntax changes. I just don't remember what they are.

Is there a good reference for making that transition again, but returning to C? If it explains the changes in C99 (and later?) that's even better.

+1  A: 

Herbison and Steele: C: A Reference Manual, Fifth Edition may be of help w.r.t C99. Also, read up on the standard, the papers available at open-std.org. And finally, the compiler/tool-chain documentation you are plan to use. The latter puts everything in perspective -- as to how much you need to re-learn.

dirkgently
560 pages seems a bit much for a "quick reference". I don't need to learn C from scratch. I was hoping for something with a few pages of the main gotchas - something to save me that first few hours of swearing as every other line of code turns out wrong, basically. Mind you, it turns out I don't have a single C book any more, so maybe that book makes sense. But it still seems a bit big. As for standards - yes, I probably should buy a few of those.
Steve314
I don't think you'll need to read the whole of it. Having a book in hand helps.
dirkgently
+5  A: 

As dirkgently suggests, Harbison and Steele is a good reference, but I don't find it useful to brush up on. To retrain your mind, I have these suggestions:

  1. Reread Kernighan and Ritchie

  2. Optional: read Peter van der Linden's superb Expert C Programming: Deep C Secrets.

  3. Don't forget libraries! Look at P. J. Plauger's book The Standard C Library, or just go to http://dinkumware.com/ (Plauger's company) and browse their excellent documentation of the C99 libraries.

  4. Standard C lacks data-structure libraries. Fortunately there is an excellent, free 3rd-party library that fills several voids: Dave Hanson's C Interfaces and Implementations.

Norman Ramsey
Harvey
+1 for the van der Linden recommendation. It's really that good.
Dan
+1  A: 

Not enough but a good starter : C for C++ Programmers

Soufiane Hassou
That looks like a good starting point - but I'm fairly sure it's not up to date. For example, it tells me not to use "//" for comments - I'm sure that's now valid in C. I was shocked by the sight of "<<" and ">>" in a list of unavailable features - until I realised it meant for streaming, not for bit-shifts.
Steve314
A: 

C for Programmers, by Leendert Ammeraal, is by far the best thing I have seen along these lines. Unfortunately, it is almost 20 years old, hard to find, and (obviously) not up to date on C99.

John R. Strohm
He probably isn't using C99 if he's running into missing things other than classes and templates.For example, C++ added inline functions, mid-scope variable declaration, and single-line comments, all of which got picked up by C but not by many embedded C compilers. Even if he uses C99 part of the time, he'll appreciate knowing the gotchas present in classic C.
Ben Voigt
+1  A: 

Not a book but read GTK+ source code. It may be fugly but it's got some of the best C source code I've ever read.

cheez
That'd be a big read - care to suggest a particularly interesting file or two?
Steve314
Take a look at how GtkObject is implemented as well as the closures.
cheez
A: 

Try the following link, I have found it good for reference:

http://www.techbooksforfree.com/ccpp.shtml

Also Sarafi Books or Books24x7, (you have access to both using either ACM or IEEE membership), are excellent references for technical books.

Also, nothing can beat the K&R:

http://www.amazon.com/exec/obidos/ASIN/0131103628

http://www.amazon.com/exec/obidos/ASIN/013089592X

I think the above should give you enough reading material to last for a few weeks and you will emerge as an accomplished C programmer. All the Best. :-)

gagneet