头文件包含两种,系统头文件和自定义头文件,系统头文件不说了,格式统一,自定义头文件在包含的时候要注意路径,其实是头文件与主文件的相对位置关系的问题。
ps:另外,LInux和Windows下也有所区别。
举4个例子,应该就能看明白了。
一.
这种情况下,在main.c中包含头文件如下:
#include “fish.h” 或
#include “./fish.h” (Linux) or #include “.\fish.h” (Windows)
二.
这种情况下,在main.c中包含头文件如下:
#include “…/fish.h” (Linux) or #include “…\fish.h” (Windows)
三.
这种情况下,在main.c中包含头文件如下:
#include “…/文件夹2/fish.h” (Linux) or #include “…\文件夹2\fish.h” (Windows)
四.
这种情况下,在main.c中包含头文件如下:
#include “文件夹3/fish.h” (Linux) or #include “文件夹3\fish.h” (Windows)
作者:Jack Frost
来源:CSDN
原文:https://blog.csdn.net/zhi11235813/article/details/80741338
版权声明:本文为博主原创文章,转载请附上博文链接!