Thread: ANSI/ISO C and K&R C?

  1. #1
    Registered User
    Join Date
    Sep 2005

    ANSI/ISO C and K&R C?

    while surfing some sites and reading the history of C and so i read alot that there;s like diff versions of C ansi and K&R so what's the diff?which is better or more spread?and should i check to see before i read any tutorial if it teaches the ansi or K&R?thanks for help.

  2. #2
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    West Virginia
    K&R C is the original version of the C programming language that was developed along with the eary versions of the Unix operating system. It was described in the book "The C Programming Language", by Brian W. Kernighan and Dennis M. Ritchie.

    Many years later, many variants of the language existed with different interpretations and different extensions that addressed some of the shortcomings of the original specification and added some "modern" features, such as stronger type checking. An ANSI committee was formed to come up with a core standard for the C language, and this is what ANSI/ISO C is. There have been two widely distributed versions of this standard, the first, known variously as C89 or C90, and the most recent, known as C99.

    You should learn ANSI C. No current C compilers that I know of (other than a few micro-C compilers that might still be around) lack the ANSI features, and it is better programming practice to use the ANSI style where it differs from traditional k&r style.

    As for C90 vs. C99 -- As a beginning programmer, this makes little difference to you; I'd recommend C90 because C99 is not yet well supported, and it would be best not to become dependent on those features that C99 adds. C90 programs will compile without problems under a C99 compiler with the exception of a few minor items (void main() is the most common one that I've seen), and so long as you stay away from trigraphs, you'll be in pretty good shape moving on into the future.

    This is, of course, my opinion. Many may disagree.
    Insert obnoxious but pithy remark here

  3. #3
    old man
    Join Date
    Dec 2005
    I use a draft of C99 when I need to check details about the language:

    It's usually easy to tell if a tutorial uses the old style by how main() is declared:
    /* old K&R style */
    main (argc, argv)
    int argc;
    char *argv[];
    /* modern protoytpe style */
    int main (int argc, char *argv[])
    /* or if argc and argv aren't used */
    int main (void)
    I'd be sure to use the modern prototypes, but for other version-specific details, turn up the warnings on your compiler and compile so that you get no warnings. These defaults (on a current version of a modern compiler) should be fine unless you need to port your code to other systems ... in this case, you might need to set some stricter flags.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. K&R solution?
    By deadhippo in forum C Programming
    Replies: 12
    Last Post: 05-09-2008, 06:36 AM
  2. K&R book help
    By HLA91 in forum C Programming
    Replies: 4
    Last Post: 04-17-2008, 03:12 PM
  3. Help with K&R Book Exercise
    By Alejandrito in forum C Programming
    Replies: 5
    Last Post: 03-11-2008, 01:24 PM
  4. Line Counting Help (K&R)
    By smittles2003 in forum C Programming
    Replies: 9
    Last Post: 01-05-2007, 04:00 PM
  5. Exercise 2-6 K&R help
    By allix in forum C Programming
    Replies: 19
    Last Post: 08-18-2006, 09:25 AM