https://www.cnblogs.com/jerrybaby/p/6130574.html
不是很明白这个网址里说的意思,
百度查的头文件的编写方式又和这里面说的不一样。
https://www.cnblogs.com/jerrybaby/p/6130574.html
不是很明白这个网址里说的意思,
百度查的头文件的编写方式又和这里面说的不一样。
这个文章乱写
#include<function.h>
int add(int a,int b)
{
return a+b;
}
这里包括不包括头文件都没区别
# include<stdio.h>
# include<function.h>
int main()
{
int a = 1,b =2;
int c = add(a,b); //这里是对function.c中的add函数的调用
printf("c=%d",c);
return 0;
}
这里包括了会编译错,因为头文件的函数没有实现
头文件应该修改为
extern int add(int a,int b);
另外,为了防止重复包含头文件,出现多行定义,还应该用条件编译
#ifndef FUNCTION_H
#define FUNCTION_H
include<stdio.h>
extern int add(int a,int b);
#endif