What are the major differences between ANSI C and K&R C?

后端 未结 11 1456
不知归路
不知归路 2020-11-29 04:10

The Wikipedia article on ANSI C says:

One of the aims of the ANSI C standardization process was to produce a superset of K&R C (the first publishe

11条回答
  •  迷失自我
    2020-11-29 04:19

    The major differences between ANSI C and K&R C are as follows:

    • function prototyping
    • support of the const and volatile data type qualifiers
    • support wide characters and internationalization
    • permit function pointers to be used without dereferencing

    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&R C compiler.

    Example: to declares a function foo and requires that foo take two arguments

     unsigned long foo (char* fmt, double data)
     {
          /*body of foo */
     }
    

提交回复
热议问题