Declaration and prototype difference

前端 未结 4 2133
盖世英雄少女心
盖世英雄少女心 2021-02-07 11:45

What is the difference between declaration and prototype in C? In which situations they are called declarations and in which prototypes?

4条回答
  •  悲&欢浪女
    2021-02-07 12:37

    • A function declaration is any form of line declaring a function and ending with ;.

    • A prototype is a function declaration where all types of the parameters are specified.

    Example, prototype function declaration: void func (void);
    Example, non-prototype function declaration: void func ();.

    Non-prototype function declarations is an obsolescent feature (6.11.6) that may get removed from the C language. Therefore you should always use prototype format and never anything else.

提交回复
热议问题