admin管理员组

文章数量:1530273

2024年5月1日发(作者:)

C语言文件包含与头文件写法

C语言文件包含的处理方法:

(1)处理时间:(#include)预处理阶段

(2)处理方法:在预处理阶段,系统自动对#include命令进行处理。具体做法是:

将包含文件的内容复制到包含语句(#include)处,得到新的文件,然后对新的文件进行

编译。

一般情况下包含文件分为两种:包含.h 文件和包含.c文件

包含.c文件的编译和编译多文件程序(包含.h的文件就是如此) 是不同的。

(1)包含.c文件

[cpp] view plaincopy

/*file1:main.c */

#include

//#include "fun.c"

int main()

{

int a = 5, b = 19;

c = a;

sun(a, b);

printf("rn c = %drn", c);

return 0;

}

/*end of file1*/

[cpp] view plaincopy

[cpp] view plaincopy

/*file2: fun.c*/

int c = 0;

void sun(int a, int b)

本文标签: 文件包含处理C语言头文件