Skip navigation

C syntax reference

878 Views 13 Replies Latest reply: Jun 23, 2012 6:27 AM by alhaynes RSS
mark133 Level 1 Level 1 (55 points)
Currently Being Moderated
Jun 20, 2012 10:29 PM

I'm trying to find a good, thorough, C syntax reference to help save time on the mistakes with the details of the syntax.

 

Are there any suggestions more efficient and orderly than simply going around fumbling with bits and pieces of code and learning the details through mistakes?

iMac
  • X423424X Level 6 Level 6 (14,190 points)
    Currently Being Moderated
    Jun 21, 2012 12:42 AM (in response to mark133)

    My favorite book, way back when, was the following:

     

    C: A Reference Manual

    By Samuel P. Harbison, Guy L. Steele

    Published Feb 21, 2002 by Prentice Hall.

  • X423424X Level 6 Level 6 (14,190 points)
    Currently Being Moderated
    Jun 21, 2012 12:05 PM (in response to mark133)

    You are asking some very basic C questions where I think a book like what I mentioned would be of more use to you than just a language specification.

     

    You don't want C89, C99, just C.  Preferably ANSI C.

  • steve359 Level 6 Level 6 (12,035 points)
    Currently Being Moderated
    Jun 21, 2012 12:10 PM (in response to mark133)

    With respect to X423424X ...

     

    I have carried "The C Programming Language", written first by Brian Kernighan and Dennis Ritchie (modeied/updated many times since) ever since 1988.  250 pages of "very good reference, not the best teacher though".  Prentice Hall, ISBN 0-13-110362-8.

     

    But then learning is a very individual thing, with individual responses to the same book.

  • X423424X Level 6 Level 6 (14,190 points)
    Currently Being Moderated
    Jun 21, 2012 12:31 PM (in response to mark133)

    If you want a cut and dry reference manual then that would be the definitive ISO standard:

     

    Programming language - C (ISO/IEC 9899:1990)

     

    http://www.winapi.co.kr/pds/doc/ISO-C-FDIS.1999-04.pdf

     

    This is definitely not for learning the language.  It's pure reference.

     

    And Steve359 is right.  It's been a lot of years since I had to pull those books off my bookshelf and the old Kernighan and Richie C book was the book I believe I originally used to learn C.  Forgot all about it. [Hmm, under a bright light I think the edges of mine are starting to turn yellow.]

  • Keith Barkley Level 5 Level 5 (5,140 points)
    Currently Being Moderated
    Jun 21, 2012 12:40 PM (in response to mark133)

    Either Harbison and Steele or K&R would be fine for you. One of the best online references is:

    http://c-faq.com/

     

    K&R - Kernigham and Richie "The C Programming Language" would probably be best.

  • Keith Barkley Level 5 Level 5 (5,140 points)
    Currently Being Moderated
    Jun 21, 2012 12:45 PM (in response to mark133)

    And to answer your questions:

    ! is the C logical not operator. It can be used in any expression, but gives strange results in an arithmetic context!

     

    However, != is a single operator, the not equals.

     

    The %c et al mean *nothing* in a general C string, they only work in a "format specifier" context like printf(). They tell printf() what arguments to expect and how to print them. %s says that the argument is a '\0' terminated string.

     

    I don't know what you mean by "slash before or after the quotes" a \" in a string says to print a " and not terminate the string

  • steve359 Level 6 Level 6 (12,035 points)
    Currently Being Moderated
    Jun 21, 2012 12:55 PM (in response to mark133)

    const char *Name ...

     

    "char *" means pointer to a character. C is all about pointers and memory referencing.  A quite necessary topic.

     

    As to "const char *Name" ... refresh my memory forum ... is that a "constant pointer to a char" or a "pointer to a constant (unchangin) char"?  Or is that particular problem just with C++?

  • Keith Barkley Level 5 Level 5 (5,140 points)
  • steve359 Level 6 Level 6 (12,035 points)
    Currently Being Moderated
    Jun 21, 2012 3:43 PM (in response to mark133)

    Jst for the record ... the K&R book I carry around is stil in print ... about $45 at Amazon for the latest (they tweak it as needed, but have not replaced it wholesale) version.

  • alhaynes Calculating status...
    Currently Being Moderated
    Jun 23, 2012 6:27 AM (in response to steve359)

    A pdf of the 1988 manual is available online (somewhere).I don't remember where I stumbled upon it, but it came up as I was (frantically) googling for C info a few months ago.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.