<p>The <a href="http://en.wikipedia.org/wiki/ANSI_C" rel="noreferrer">Wikipedia article on ANSI C</a> says:</p>

<blockquote>
  <p>One of the aims of the ANSI C standardization process was to produce a superset of K&amp;R C (the first published standard), incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as function prototypes (borrowed from the C++ programming language), and a more capable preprocessor. The syntax for parameter declarations was also changed to reflect the C++ style.</p>
</blockquote>

<p>That makes me think that there are differences. However, I didn't see a comparison between K&amp;R C and ANSI C. Is there such a document? If not, what are the major differences?</p>

<p>EDIT: I believe the K&amp;R book says "ANSI C" on the cover. At least I believe the version that I have at home does. So perhaps there isn't a difference anymore?</p>

[{'answer_id': 22504, 'author': 'DrPizza', 'author_id': 2131, 'author_profile': 'https://Stackoverflow.com/users/2131', 'pm_score': 1, 'selected': False, 'text': '<p>The biggest single difference, I think, is function prototyping and the syntax for describing the types of function arguments.</p>\n'}, {'answer_id': 22516, 'author': 'FreeMemory', 'author_id': 2132, 'author_profile': 'https://Stackoverflow.com/users/2132', 'pm_score': 4, 'selected': False, 'text': '<p>There are some minor differences, but I think later editions of K&amp;R are for ANSI C, so there\'s no real difference anymore.<br>\n"C Classic" for lack of a better terms had a slightly different way of defining functions, i.e.  </p>\n\n<pre><code>int f( p, q, r )  \nint p, float q, double r;  \n{  \n    // Code goes here  \n}\n</code></pre>\n\n<p>I believe the other difference was function prototypes. Prototypes didn\'t have to - in fact they couldn\'t - take a list of arguments or types. In ANSI C they do.</p>\n'}, {'answer_id': 22547, 'author': 'Chris Conway', 'author_id': 1412, 'author_profile': 'https://Stackoverflow.com/users/1412', 'pm_score': 6, 'selected': True, 'text': '<p>There may be some confusion here about what "K&amp;R C" is. The term refers to the language as documented in the first edition of "The C Programming Language." Roughly speaking: the input language of the Bell Labs C compiler circa 1978.</p>\n\n<p>Kernighan and Ritchie were involved in the ANSI standardization process. The "ANSI C" dialect superceded "K&amp;R C" and subsequent editions of "The C Programming Language" adopt the ANSI conventions. "K&amp;R C" is a "dead language," except to the extent that some compilers still accept legacy code.</p>\n'}, {'answer_id': 31594, 'author': 'tuxedo', 'author_id': 3286, 'author_profile': 'https://Stackoverflow.com/users/3286', 'pm_score': 4, 'selected': False, 'text': '<p>Function prototypes were the most obvious change between K&amp;R C and C89, but there were plenty of others.  A lot of important work went into standardizing the C library, too.  Even though the standard C library was a codification of existing practice, it codified <em>multiple</em> existing practices, which made it more difficult.  P.J. Plauger\'s book, <a href="https://rads.stackoverflow.com/amzn/click/com/0131315099" rel="noreferrer" rel="nofollow noreferrer"><em>The Standard C Library</em></a>, is a great reference, and also tells some of the behind-the-scenes details of <em>why</em> the library ended up the way it did.</p>\n\n<p>The ANSI/ISO standard C is very similar to K&amp;R C in most ways.  It was intended that most existing C code should build on ANSI compilers without many changes.  Crucially, though, in the pre-standard era, the semantics of the language were open to interpretation by each compiler vendor.  ANSI C brought in a common description of language semantics which put all the compilers on an equal footing.  It\'s easy to take this for granted now, some 20 years later, but this was a significant achievement.</p>\n\n<p>For the most part, if you don\'t have a pre-standard C codebase to maintain, you should be glad you don\'t have to worry about it.  If you do--or worse yet, if you\'re trying to bring an old program up to more modern standards--then you have my sympathies.</p>\n'}, {'answer_id': 55632, 'author': 'Ferruccio', 'author_id': 4086, 'author_profile': 'https://Stackoverflow.com/users/4086', 'pm_score': 2, 'selected': False, 'text': '<p>Another difference is that function return types and parameter types did not need to be defined. They would be assumed to be ints.</p>\n\n<pre><code>f(x)\n{\n    return x + 1;\n}\n</code></pre>\n\n<p>and</p>\n\n<pre><code>int f(x)\nint x;\n{\n    return x + 1;\n}\n</code></pre>\n\n<p>are identical.</p>\n'}, {'answer_id': 576546, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>The difference is:</p>\n\n<ol>\n<li>Prototype</li>\n<li>wide character support and internationalisation</li>\n<li>Support for const and volatile keywords</li>\n<li>permit function pointers to be used as dereferencing</li>\n</ol>\n'}, {'answer_id': 5143249, 'author': 'vivek shukla', 'author_id': 637829, 'author_profile': 'https://Stackoverflow.com/users/637829', 'pm_score': 3, 'selected': False, 'text': '<ol>\n<li>function prototype.</li>\n<li>constant &amp; volatile qualifiers.</li>\n<li>wide character support and internationalization.</li>\n<li>permit function pointer to be used without dereferencing.</li>\n</ol>\n'}, {'answer_id': 6237726, 'author': 'VISHNU CHOUDHARY', 'author_id': 784068, 'author_profile': 'https://Stackoverflow.com/users/784068', 'pm_score': 2, 'selected': False, 'text': '<ul>\n<li>FUNCTION PROTOTYPING:ANSI C adopts c++ function prototype technique where function definaton and declaration include function names,arguments t,data types and return value data types.function prototype enable ANSI ccompilers to check for function call in user program that passes invalid number number of argument or incompatiblle argument data types.these fix a major weakness of the K&amp;R C compilers:invalid call in user program often passes compilation but cause program to crash when they are executed</li>\n</ul>\n'}, {'answer_id': 15125979, 'author': 'Nagarjuna Yalamanchili', 'author_id': 2117814, 'author_profile': 'https://Stackoverflow.com/users/2117814', 'pm_score': 2, 'selected': False, 'text': "<p>The major differences between ANSI C and K&amp;R C are as follows:</p>\n\n<ul>\n<li>function prototyping</li>\n<li>support of the const and volatile data type qualifiers</li>\n<li>support wide characters and internationalization</li>\n<li>permit function pointers to be used without dereferencing</li>\n</ul>\n\n<p>ANSI C adopts c++ function prototype technique where function definition and declaration include function names,arguments' data types, and return value data types. Function prototype enable ANSI C compiler to check for function calls in user programs that pass invalid numbers of arguments or incompatible arguments data types. These fix major weakness of the K&amp;R C compiler.</p>\n\n<p>Example: to declares a function foo and requires that foo take two arguments</p>\n\n<pre><code> unsigned long foo (char* fmt, double data)\n {\n      /*body of foo */\n }\n</code></pre>\n"}, {'answer_id': 38214128, 'author': 'supercat', 'author_id': 363751, 'author_profile': 'https://Stackoverflow.com/users/363751', 'pm_score': 2, 'selected': False, 'text': '<p>A major difference nobody has yet mentioned is that before ANSI, C was defined largely by precedent rather than specification; in cases where certain operations would have predictable consequences on some platforms but not others (e.g. using relational operators on two unrelated pointers), precedent strongly favored making platform guarantees available to the programmer.  For example:</p>\n\n<ol>\n<li><p>On platforms which define a natural ranking among all pointers to all objects, application of the relational operators to arbitrary pointers could be relied upon to yield that ranking.</p></li>\n<li><p>On platforms where the natural means of testing whether one pointer is "greater than" another never has any side-effect other than yielding a true or false value, application of the relational operators to arbitrary pointers could likewise be relied upon never to have any side-effects other than yielding a true or false value.</p></li>\n<li><p>On platforms where two or more integer types shared the same size and representation, a pointer to any such integer type could be relied upon to read or write information of any other type with the same representation.</p></li>\n<li><p>On two\'s-complement platforms where integer overflows naturally wrap silently, an operation involving an unsigned values smaller than "int" could be relied upon to behave as though the value was unsigned in cases where the result would be between INT_MAX+1u and UINT_MAX and it was not promoted to a larger type, nor used as the left operand of <code>&gt;&gt;</code>, nor either operand of <code>/</code>, <code>%</code>, or any comparison operator.  <em>Incidentally, the rationale for the Standard gives this as one of the reasons small unsigned types promote to signed</em>.</p></li>\n</ol>\n\n<p>Prior to C89, it was unclear to what lengths compilers for platforms where the above assumptions wouldn\'t naturally hold might be expected to go to uphold those assumptions anyway, but there was little doubt that compilers for platforms which could easily and cheaply uphold such assumptions should do so.  The authors of the C89 Standard didn\'t bother to expressly say that because:</p>\n\n<ol>\n<li><p>Compilers whose writers weren\'t being deliberately obtuse would continue doing such things when practical without having to be told (the rationale given for promoting small unsigned values to signed strongly reinforces this view).</p></li>\n<li><p>The Standard only required implementations to be capable of running one possibly-contrived program without a stack overflow, and recognized that while an obtuse implementation could treat any other program as invoking Undefined Behavior but didn\'t think it was worth worrying about obtuse compiler writers writing implementations that were "conforming" but useless.</p></li>\n</ol>\n\n<p>Although "C89" was interpreted contemporaneously as meaning "the language defined by C89, plus whatever additional features and guarantees the platform provides", the authors of gcc have been pushing an interpretation which excludes any features and guarantees beyond those mandated by C89.</p>\n'}, {'answer_id': 41495304, 'author': 'OldBlueBear', 'author_id': 7381440, 'author_profile': 'https://Stackoverflow.com/users/7381440', 'pm_score': -1, 'selected': False, 'text': '<p>Despite all the claims to the contary K&amp;R was and is quite capable of providing any sort of stuff from low down close to the hardware on up.\nThe problem now is to find a compiler (preferably free) that can give a clean compile on a couple of millions of lines of K&amp;R C without out having to mess with it.And running on something like a AMD multi core processor. </p>\n\n<p>As far as I can see, having looked at the source of the GCC 4.x.x series there is no simple hack to reactivate the -traditional and -cpp-traditional lag functionality to their previous working state without without more effor than I am prepered to put in. And simpler to build a K&amp;R pre-ansi compiler from scratch. </p>\n'}]
['https://Stackoverflow.com/questions/22500', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/572/']