Slashdot Mirror


Advanced C Programming by Example

LizardKing has sent us a review of John Perry's Advanced C Programming by Example. Covering topics such as pointer trickery, string manipulation and dynamic data structures, this book is designed for those of you who are looking to fine-tune your C skills. Click below for more information. Advanced C Programming by Example author John W. Perry pages publisher PWS rating 9/10 reviewer LizardKing ISBN summary An unusualy well written C textbook, that picks up where most other programming guides finish off. The Scenario

Having been given a book voucher for Christmas, I duly trotted off to Blackwell's bookshop in Oxford to see what I could spend it on. I did the obligatory check for new O'Reilly titles, before turning to the C books. A hardback copy of Kamp II to replace my dog-eared paperback would've been nice, but first I decided to flick through Advanced C Programming by Example. The contents page promised examples of pointer trickery, string manipulation and dynamic data structures. I consequently bought it.

What's Bad?

There is very little to fault this book on. It is written in a clear and enjoyable manner, which is about the best you can hope for from a programming guide. My only real criticism is the lack of a bibliography. For instance, cryptography is mentioned in the chapter on bit manipulation, but no references to further reading are given.

What's Good?

The introduction explains the rationale behind producing another C book by pointing to the dearth of intermediate level texts. The author also criticises the current emphasis on OO languages with their larger vocabulary and more abstract concepts.

The first chapter highlights the importance of coding style to aid maintainability, and the valid use of features like the ternary and comma operators. This is followed by an excellent review of pointer theory. I always judge a C book by how clearly it describes the purpose of pointers - and this one does it superbly.

Subsequent chapters contain in depth analysis of key data structures like singly and doubly linked lists, binary trees, etc. While most C books include examples of these, they are particularily well described and illustrated. Other important techniques like hashing (both to memory and disk) are introduced, with common pitfalls highlighted.

The bit manipulation chapter is comparable with those in other C texts, but is unusually clear and consistent. The same can be said of the advanced I/O chapter.

The chapter on string manipulation uses dynamic memory allocation, arrays of pointers and the more obscure ANSI C string functions for 'real world' examples. This is another area where many C books fall down, ignoring the fact that the strings many programmers deal with cannot be expected to fit into fixed length arrays.

The final "Pot-Pourri" chapters include a discussion of complex function declarations that both expect and return function pointers. A number of other rarely described but expressive features are also covered.

So What's In It For Me?

If you consider yourself a C expert, then this book may be superfluous, as it covers ideas and principles you should know intimately. But if like me you're spending more time with scripting languages like Perl, you may need a handy reference for those forays back into C.

Buy this book here.

Table of Contents
  1. Optimal C Coding Style
  2. Review of Standard Pointer and Array Operations
  3. The Linear Dynamic Data Structures: Stacks, Queues and Linked Lists
  4. Advanced String Handling
  5. Advanced Input and Output
  6. Bit Manipulation
  7. Recursion and Binary Trees
  8. Multidimensional Arrays and Arrays of (Non-Char) Pointers
  9. Potpourri: Part One
  10. Potpourri: Part Two
  11. Answers to Selected Exercises

47 comments

  1. C is dumb by Anonymous Coward · · Score: 0

    They should have a book on C++ instead!

    1. Re: C is dumb by Anonymous Coward · · Score: 0

      C is to C++ as Lung is to Lung cancer.

  2. Promising by Anonymous Coward · · Score: 0

    This sounds promising... I'll probably pick it up based on this synopsis.

  3. Function Pointers? by Anonymous Coward · · Score: 0

    Nice review; thanks.

    Does the book cover function pointers in any
    detail?

  4. my books and pointers == bad mix by Anonymous Coward · · Score: 0

    all the c books i have (or rather the ones that are required texts for school) fall short in terms of pointers. one chapter out of 15 is lacklustre. i might pick this book up based on the review.

    later
    tyler

  5. C: 1960's technology, today by Anonymous Coward · · Score: 0

    Common folks, the C language is 1960's technology. C is great for writing error-prone programs. (If you don't believe me, check out the Fuzz paper where about 25% of common unix utility programs crash when you give them random input).

    One of the posters here wanted to learn more about function pointers. For almost any task, a decent programming language doesn't need pointers (user manipulable machine addresses). All you need is references. With references you get safety, and you don't need lose any power...

  6. c stuff by Anonymous Coward · · Score: 0

    anyone reccomend a good encryption book for c/c++ ?

  7. Wow, I know this guy. by Anonymous Coward · · Score: 0

    Years ago I took a C course taught by Greg Perry
    at Tulsa Junior College before he started writing books full time. He was a really good teacher, so I expect his book to be very good as well.

  8. all you idiots putting down C by Anonymous Coward · · Score: 0

    making fun of C is making fun of the foundation
    on which all you know is built.

  9. the title! by Anonymous Coward · · Score: 0

    Hmmm... the title isn't *quite* similar enough to the titles of other famous books for me... how about this one:

    "The Art of Advanced C Programming by Example for Dummies in a Nutshell"

    how about that, is that vaguely familiar enough for you?

  10. Where is the FUZZ PAPER you speak of? by Anonymous Coward · · Score: 0

    Citations? Thanks!

  11. C: 1960's technology, today by Anonymous Coward · · Score: 0

    > Function pointers have come in pretty handy to me as
    > an elegant and fast way to call different functions
    > depending on the program's state.

    Function pointers are handy... but guess what?... A language doesn't need pointers to do the equivalent thing. All you need is references to functions... The programmer doesn't need to manipulate machine addresses directly... the programming language should take care of that for you. References give you all the power of pointers, but with safety.

    Pointer errors are one of the most common errors in C programs.

  12. C is dumb by Anonymous Coward · · Score: 0

    The thing i like about java is that all classes inherit from Object. I prefer to use/code containers this way than with c++ template. But i know a lot of people prefer generic programming, i would like to know why? what are the advantage?

    i learn OO with C++, but now i prefer java, the syntax is much nicer. never used objective-c but the syntax looks very special..


    cob2k25@iebgener.org

  13. Well I am interested.. by Anonymous Coward · · Score: 0

    I am/was interested in purchasing the book, however I wanded to first browse through it before purchasing it. Money is tight when your a student :]. Unfortunately, 5 different book stores all indicated that they were out of stock. :[.

  14. Whats better? by Anonymous Coward · · Score: 0

    If C sucks so bad then is there anything better that compiles natively. Java may be a great language but I have no need for cross platform compatibility and it just makes it slow.

  15. Why C is not my favorite programming language by Anonymous Coward · · Score: 0

    >
    > for sheer expressive power, Perl is unbeatable
    >

    Only in a very limited domain. In most domains, Perl is not very good at abstracting complexity. Can you imagine wrapping some really nasty libraries in Perl to make the library easier to use, say Microsoft's OLE for instance?

    The Dylan programming language is quite capable of doing this:

    http://www.harlequin.com/products/ads/dylan/com/ comsimplifiedtext.html

    Dylan code is also very efficient.

  16. Troll Bridge (was: C is dumb) by Anonymous Coward · · Score: 0

    Stop.

    Pay Troll.

  17. Why C is not my favorite programming language by Anonymous Coward · · Score: 0

    "but I doubt if you are very familiar with some of the other languages" Why would you assume that? How could you possibly have any idea what programming languages that person uses for what kinds of programs? (Heh, perhaps the person is developing code for, say, Python, in which case C's still pretty important for now.)

  18. Whats better? by Anonymous Coward · · Score: 0

    You'll notice from the graphs on your reference, that although C/C++ scores very low on the comlexity scale (ie, it is more complex than most languages) even MSVC++, a microsoft implementation, scores as one of the highest contenders as far as speed goes... which means, if the major issue for your project is speed, use C/C++.

  19. Alogorithm books ... not for me by Anonymous Coward · · Score: 0

    I agree, but I have met more examples of programmers who write inefficient algorythms, and who don't even know what a binary tree is than I have over educated theorists.

  20. Wow, I know this guy. by Anonymous Coward · · Score: 0

    My mistake. I guess I assumed it was his because of the "___ by Example" title. A lot of his books follow that form.

  21. C: 1960's technology, today by Anonymous Coward · · Score: 0

    id Software uses ANSI C for core technology. That
    is the claim by Brian Hook (in an article on Quake II
    in Game Developer magazine). I have never had an
    id Software product crash on me. Maybe I was just
    lucky, eh?

  22. Are we talking Pascal here... by Anonymous Coward · · Score: 0

    1. If that code snippet's supposed to be C, you do realize that you're making an assignment and not an equivalency test, no?
    2. In my experience, "language zealots", for *any* programming language, often do not have much breadth or of programming experience. Nothing at all to do with C (check the various "vs." language "wars" on USENET).

  23. C is dumb by Anonymous Coward · · Score: 0

    I tried learning C++ but I think OO programming is hard, C is much easier..

  24. C: power to the people by Tom · · Score: 1

    while I agree that C is error-prone, it's also the most powerful language I've ever encountered, and that's exactly why I stick with it.
    C is very much like unix: more power than you can handle, and if you burn yourself, it's your fault. I've yet to find a C problem that way not caused by bad design and/or bad implementation.
    and taking care is the prize you pay for power. so if you can't handle it, then stay away from it. but stop telling me what to do. thank you.

    --
    Assorted stuff I do sometimes: Lemuria.org
  25. Are we talking Pascal here... by Dave+Fiddes · · Score: 1

    Or ada or any other strongly typed language...

    I spend a lot of my spare time programming embedded systems in C...and some of it is a real grind compared to the day job programming in Delphi/Object Pascal. What language would allow this!

    if ( Finished = TRUE )
    {
    PerhapsIllNeverGetRun();
    }

    It is my experience that C zealots rarely know many other languages

  26. PICK ON C? GO TO JAIL! :) by jabbo · · Score: 1

    Big deal, so you use a typedef to mask this in the libraries. What's your point?

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  27. Why C is not my favorite programming language by kip3f · · Score: 1

    1) People write programs to solve problems.
    2) Problems are complicated (in general), and require
    complicated solutions.
    3) "Efficicent" [1] languages like C/C++ make the programmer
    deal with complexities that are unrelated to the actual problem.
    4) Hence C is not my favorite programming language.
    [1] When people say "C is efficient", they are talking about
    the speed of the resulting executable. OTOH 99.44% of the time,
    it is much better to optimize *Programmer Efficiency*.

    --
    ****Gfx Scrollbar Special case hit!!*****
  28. Perl by kip3f · · Score: 1

    Sure. At the moment, Perl is my favorite programming language. There are a few misfeatures, like allowing both $foo and @foo, my $bar has nothing to do with *bar, debugging can be challenging due to the permissive nature of the language, no symbol for handles (they are a first class type, and deserve to be treated like one!).

    What I would really like to see is increased flexibility in the typeglob. This should be a (C style) union [typesafe ;-)], where you can add new types (eg: a tree type). Also, more TIE* stuff.

    --
    ****Gfx Scrollbar Special case hit!!*****
  29. Price Check by Ralph+Bearpark · · Score: 1

    Amazon $45.95
    AlphabetStreet (UK) $34.25
    BarnesAndNoble $44.95
    Dymocks (AUS) US$31.29
    Spree $36.76

    Regards, Ralph.

  30. C is dumb? by W84thend · · Score: 1

    C is the basis of C++ (A real hack job of a programming language held together with baling wire and duct tape to give C programmers an OO language (it's not a real OO environment, but an incredible simulation!) without having to learn a whole new language.).
    If you think C++ is so great for things like kernal programming then look closer at why Win95 crashes so much. Did you ever notice that modules don't always load in the same sequence?
    Saying that C is dumb just proves what an asenine egotist you are. You don't understand the basis of the tools you are using.
    There are very good reason's why 1. kernal programming, 2. embedded systems, 3. low level devices are done in C and not C++.
    Java will one day surplant C++ as the standard OO design platform and not a day too soon. When that happens, C will still be used widely for many tasks which are unsuited to Java.
    If you don't understand these basic issues, then I recommend you go back to Visual Basic programming and leave the system programming to people with more brains than you have.

  31. PICK ON C? GO TO JAIL! :) by Drizzt · · Score: 1

    Listen up C++ programs!

    Do this in C++...

    Cross platform/compiler. No real standard, no real cross platorm=no real widespread usage for cross platform work.

    'nuff said.

    :)

    -Alan

    --
    -- Man was created on the seventh day when god was tired. --
  32. Learning C = Learning C++ by Mark+Storer · · Score: 1

    C++ is a SUPERSET of C. Everything a wannabe hippster C++ programmer might learn from this book WILL APPLY DIRECTLY TO C++.

    I use C++ and/or Java every day. You can bet I'll read this book sooner or later to make myself a better programmer in languages based on C (including Objective-C, for all you NeXT/Mac types out there).

    Sokwuitcherbichin!

    --
    --Mark
  33. Calm down ... by LizardKing · · Score: 1

    I agree that a more accurate title for Perry's
    book would be `Intermediate C Programming', but
    your distinctly rabid sentiments are wide of the
    mark.

    Deep C Secrets is a book that I mean to check out
    at some point, but I was a little less than
    enamoured with van der Linden's `Just Java' book.
    It offers a lot of very good insights into Java,
    but is lacking in example code.

    As an aside, the classic view that C can *only* be
    learnt from KnR II is a little suspect. It is
    a great introductory text, and an even better
    reference for C syntax, but it is a little too
    bare bones for a standalone C tutorial.

  34. C is dumb by Vitus+Wagner · · Score: 1

    If you've know a bit of C (or C++, it doesn't matter), you know that
    C++ means "C grows larger, but result is as before". If Stroustroup had really intended
    to build general replacement for C, not a language
    which works better than C in _particular_ areas,
    he'd call it ++C

  35. I rather would judge by products written on it. by Vitus+Wagner · · Score: 1

    See:
    apache - is written on C
    Emacs - written on Lisp (so its way for OO programs)
    Linux kernel - written on C
    Gimp - written on C.
    Perl - written on C
    Tcl - written on C

    So, where are good programs written on C++?
    Nothing to name except KDE. But there is a lot
    of problems with it. Is there web-servers war?
    No - anyone prefer to contribute to apache.
    But there is Desktop war, becouse too much people
    don't like either Qt or C++ at all and starting
    altertaitve desktop projects.

    Consider number of programmers who would be
    able to peer review and contribute to your code.
    If you write in C every C _and_ C++ programmer
    counts. If you write in C++, there are a lot
    of people (and, more imprtant, compiliers)
    who wouldn't understand what are you trying to
    say.

  36. Also, expert C programming by andrew+cooke · · Score: 1

    People might like to check out Van Der Linden's "Expert C Programming (Deep C Secrets)" - it's a very odd book, full of many random snippets, but it does contain some nuggets of useful wisdom.

    Thanks for the review - I'll have a look for this book next time are out shopping...

    Cheers,

    Andrew

    --
    http://www.acooke.org
  37. Can't judge a language by the people who use it by Anil · · Score: 1

    I mean, I know some good programmers that are forced to use VisualBasic; doesn't make visual basic any better than the horrid excuse for a scripting language that it is.

    I know some poor coders who try to code in C; doesn't make C a poor language.

  38. C is dumb by GypC · · Score: 1

    C++ is dumb... needlessly complex. ObjectiveC is much nicer.

  39. the title! Let's do this! by Bertelsmanniac · · Score: 1

    "Rescued By: Core Teach Yourself Zen and the Art of Advanced C Programming for C and C++ Programmers by Example for Dummies in a Nutshell Unleashed in 24 Hours for the Complete Idiot in 7 Days

  40. C is dumb? by dmeiz · · Score: 1

    i'd take a closer look at the nitwits in redmond before laying the blame on c++. true, c++ extends c to facilitate object oriented programming. a simulation? alright, i'll give you that; but it's quick and backward compatible and that ain't bad.

  41. Price Check by NYC · · Score: 1

    I always use http://www.acses.com to search online bookstores. It is a book search engine which tells you the price of a book with shipping included.

    If you are looking for computer books look at http://www.bookpool.com. They are not indexed by acses.com, but they usually the cheapest and often out-of-stock.

    Other new bookstores that seem promising:
    http://www.shopping.com
    http://www.buybooks.com (buycomp.com rocks!)

    Never use amazon.com and barnesandnoble.com. They often lie about their selection (sure we have that in stock! oops, please wait 5 weeks)

    --
    --weenie NT4 user: bite me!
    "Computers are nothing but a perfect illusion of order" -- Iggy Pop
  42. Why buy this book? by FigWig · · Score: 1

    The ultimate guide to C has got to be K&R. No one should be allowed to program C without it. Read it. Live it. Love it.

    And if you need the linked-list-hash-table-b-tree stuff get a good algorithms book. I have heard Sedgewick (?) has written some good ones for C and C++.

    --
    Scuttlemonkey is a troll
  43. C is dumb by dxkelly · · Score: 1

    How can your learn C++ without learning C, when C is a subset of C++?

  44. Your SOOO hip by dimer · · Score: 1

    Man, I wish I was on top of the tech-wave like you are, ya know? Wait, lemme try...

    "They should have a book on Shockwave instead!"

    "They should have a book on JavaBeans instead!"

    ...whoa! If I'm ignorant and spout gay-ass buzzwords, then I'm cool! This is SOOO cool. I can't wait to tell my mom.

    (Not saying C++ is bad or anything, but I am saying that straight-up C coding is a man's language.. Heheh)


  45. C is dumb by andyz · · Score: 1

    IMHO it's not true.
    Programming language is the tool or instrument only. It can't be dumb.
    But programmer (usually not a real programmer) can. And don't forget that the C++ is only preprocessor for pure C... I think that mindless plastic box (even 450 MHz with) can't be smarter than man's brain...

  46. Why C is not my favorite programming language by Badfish · · Score: 1

    What Inefficincies in perticular are you refferring to????

    Quite frankly I LOVE C!