函数的声明

函数的声明是在文件头部进行声明
声明一个函数以后可以在定义前使用调用
可以使用extern int count;告诉编译器, 先在文件下面找找有没有这个函数, 而不是直接报错

  1. #include <stdio.h>
  2. // 提前声明一个函数
  3. void func(void);
  4. int main(){
  5. extern int count;
  6. // 在定义前调用
  7. func();
  8. printf("count:%d \n",count);
  9. count++;
  10. printf("count:%d \n",count);
  11. return 0;
  12. }
  13. int count;
  14. void func(){
  15. count++;
  16. }