#include<stdio.h>
#include"40.头文件练习.h"
int main(void)
{
printf("%lf\n", PI);
printf("%d\n", max(1, 3));
printf("%d\n", E);
return 0;
}
#define PI 3.1415
int E = 123;
int max(int x, int y)
{
if (x > y)
{
return x;
}
else
{
return y;
}
}
#include"40.头文件练习.h" 这个文件名改下试试:#include"40_头文件练习.h"
1,首先最好文件名跟工程名不要有中文
2,头文件不能有定义具体的变量或者函数,只能引用,就好比max的函数的定义不能直接放到头文件,不然会相互包含
解决方法
将头文件的内容放到源文件里面,除了#define PI 3.1415
然后头文件改成
#define PI 3.1415
extern int max(int x,int y);